Is it possible to create a slack notification channel using GKE's config connector?

201 Views Asked by At

I'm trying to use the GKE config connector to create my log based metrics, alert policies, etc. I'm stuck on how to create a slack notification MonitoringNotificationChannel.

I can see how the format should be done from here: https://cloud.google.com/config-connector/docs/reference/resource-docs/monitoring/monitoringnotificationchannel#basicauth_webhook_monitoring_notification_channel (and from the https://cloud.google.com/monitoring/api/ref_v3/rest/v3/projects.notificationChannelDescriptors/list API)

{
      "type": "slack",
      "displayName": "Slack",
      "description": "A channel that sends notifications to the third-party chat service [Slack](https://slack.com, \"Slack web site\").",
      "labels": [
        {
          "key": "auth_token",
          "description": "A permanent authentication token provided by Slack. This field is obfuscated by returning only a few characters of the key when fetched."
        },
        {
          "key": "channel_name",
          "description": "The Slack channel to which to post notifications."
        }
      ],
      "name": "projects/as-dashboard-213905/notificationChannelDescriptors/slack",
      "launchStage": "GA"
    }

Something like that

apiVersion: monitoring.cnrm.cloud.google.com/v1beta1
kind: MonitoringNotificationChannel
metadata:
  name: slack-notification
spec:
  type: slack
  labels:
    channelName: my-slack-channel
  description: Sends notifications to slack channe;
  sensitiveLabels:
    authToken:
      valueFrom:
        secretKeyRef:
          key: password
          name: slack-auth-token

However, I can't figure out how to get the actual auth token to put into a kube secret... From doing it via the UI, I'm assuming that the app token is generated as part of the initial connection, and then provided directly from the Slack Google Cloud Monitoring app to GCP itself. But how do I get that API token for reuse?

Thank you

1

There are 1 best solutions below

1
On

Store your incoming webhook URL in Secret Manager:

  1. Open the Secret Manager page in the Google Cloud console:

  2. Click Create secret.

  3. Enter a name for your secret.

  4. Under Secret value, add your incoming webhook URL for your Slack app.

  5. To save your secret, click Create secret.

You can check this documentation for reference. I hope this answers your concern.