Search code examples
google-cloud-platformmetadataalertpolicystackdriver

How to get additional information into GCP Stackdriver alert messages


We want to put more information into GCP Stackdriver alert notifications like customer contract id (e.g. 47110815), customer environment (prod/dev/test), SLA (24-7-4/24-7-8/nbd), etc. It must be machine readable (currently by alerta monitoring system via webhook) so we would prefer additional key/value fields instead of all information mashed together into documentation/content field.

GCP Stackdriver offers many fields when creating alerting policies: (https://cloud.google.com/monitoring/api/ref_v3/rest/v3/projects.alertPolicies)

most interesting is userLabels:

  • map (key: string, value: string)
  • User-supplied key/value data to be used for organizing and identifying the AlertPolicy objects.
  • The field can contain up to 64 entries. Each key and value is limited to 63 Unicode characters or 128 bytes, whichever is smaller. Labels and values can contain only lowercase letters, numerals, underscores, and dashes. Keys must begin with a letter.
  • An object containing a list of "key": value pairs. Example: { "name": "wrench", "mass": "1.3kg", "count": "3" }.

When creating policies they are shown in stackdriver but it seems like this fields are not included in alert notifications.

Is there any other option than putting all information into the documentation content field? I wanted to use this field for free-text that gives general handling instructions to service desk staff and don't like the idea of parsing machine readable data out of it.


Solution

  • At this time, Stackdriver does not allow you to customize the notifications.

    The current way to add more information on Notifications are using the documentation section [1]. You can also use variables in this field to get specific details about the alert [2].