GyeongSik Jang
GyeongSik Jang

Reputation: 83

GCP Monitoring Alert Notification Channel (Web Hook) with MS Teams

I'm trying to use Teams webhooks in a GCP monitoring notification channel. The webhook URL was created by viewing the guide below. https://learn.microsoft.com/en-us/outlook/actionable-messages/send-via-connectors

But there seems to be no action in the test connection. Can't I use the GCP Monitoring notification channel in Teams by linking it with a webhook?

Upvotes: 3

Views: 7309

Answers (2)

GyeongSik Jang
GyeongSik Jang

Reputation: 83

Clone the source from the github link and import it.

git clone https://github.com/JangGyeongSik/gcp-teams-monitoring.git

After that, create a Teams Webhook through the attached link.

https://learn.microsoft.com/en-us/microsoftteams/platform/webhooks-and-connectors/how-to/add-incoming-webhook?WT.mc_id=m365-12509-rwilliams

Edit the .env.yaml File as follows. TEAMS_WEBHOOK_URL is the previously issued URL. AUTH_TOKEN specifies an arbitrary value.

TEAMS_WEBHOOK_URL: [TEAMS_WEBHOOK_URL]
AUTH_TOKEN: gyeongsik_jang

Then, deploy the Cloud Function through the ShellFile below.

In the case of Service Account, you must be granted the following permissions in advance.

  • Monitoring Metrics Writer, Logs Writer
gcloud functions deploy gcp-monitoring-teams-trigger \
    --entry-point=F \
    --memory=128MB \
    --region=asia-northeast3 \
    --runtime=go113 \
    --env-vars-file=env.yaml \
    --trigger-http \
    --timeout=10s \
    --service-account=[SERVICE_ACCOUNT]

Create the generated Trigger URL as Monitoring Notification Channel as shown below.

Auth_Token value should be entered at the end of the URL.

https://[Cloud_Function_Trigger_URL]?auth_token=gyeongsik_jang

With this setup, you can check the Test Connection in Teams as follows. enter image description here

Thank you for reading the long post.

Gyeongsik Jang

Upvotes: 3

Foward
Foward

Reputation: 56

I have created a GitHub repo taking the code from https://github.com/Courtsite/gcp-monitoring-to-teams.git and I modified to be able to use internally with pubsub notifications to a topic and then post it to the web hook of MS Teams, with this you don't have to expose the cloud function or break some org policy.

https://github.com/foward/gcp-monitoring-to-msteams

I hope this helps...

Regards

Upvotes: 0

Related Questions