Currently, the message specified in the Document field while creating alerting policy appears in the Document field of the Stackdriver alert email. I would like to overwrite the entire email message body with my custom content. How can I overwrite the message body of Stackdriver Alert email with my custom message? Is there any other workaround to do this?
Each alerting policy specifies the following: Conditions that describe when a resource, or a group of resources, is in a state that requires you to respond. An alerting policy must have at least one condition; however, you can configure a policy to contain multiple conditions.
What is not a recommended best practice for alerts? []Configure alerting on symptoms and not necessarily causes.
You should be able to send the notification to a webhook, and this could directly be an HTTP-triggered Cloud Function.
This Cloud Function would receive all the information from the alert, and you can follow this tutorial to use SendGrid to send your alerts.
This is a lot more complex than just setting the email notifications, but also provides you with an amazing flexibility regarding alerts, as you'll be able to not just write the message however you want, but you could process the data in any way you want:
And those are just some random quick ideas I got while writing this message.
The information provided in the POST
body is this one (that's just a sample):
{
"incident": {
"incident_id": "f2e08c333dc64cb09f75eaab355393bz",
"resource_id": "i-4a266a2d",
"resource_name": "webserver-85",
"state": "open",
"started_at": 1385085727,
"ended_at": null,
"policy_name": "Webserver Health",
"condition_name": "CPU usage",
"url": "https://app.google.stackdriver.com/incidents/f333dc64z",
"summary": "CPU for webserver-85 is above the threshold of 1% with a value of 28.5%"
},
"version": 1.1
}
You can create a single webhook that handles all the alerts, or you can create a webhook on a per-policy basis to handle things separately.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With