grafana / alerting

Set of libraries used to build alerting systems at Grafana - including the Alertmanager.
GNU Affero General Public License v3.0
47 stars 42 forks source link

Customize "OPEN IN GRAFANA" widget in Google Chat #209

Open williancolognesitrimble opened 3 months ago

williancolognesitrimble commented 3 months ago

Hello,

I recently upgrade Grafana to version 9.x and previously the button "OPEN IN GRAFANA" used to have a link to the panel where it's alert comes from.

But now it always send to "alert list page" that isn't useful to analyse the alert itself because alert list do not show the metrics.

I'd like to request a way to customize this button maybe from template or something like that.

Thanks.

JacobsonMT commented 3 months ago

This change is likely caused by the automatic upgrade to Unified Alerting in 9.x. It should be possible to template the direct link to the alert by using the {{ .GeneratorURL }} field of an individual alert. Something like:

{{ range .Alerts }}
{{ .GeneratorURL }}
{{ end }}

Or if you know the alerts are all from the same rule you can just use the first one:

{{ (index .Alerts 0).GeneratorURL }}

You can find more information here: https://grafana.com/docs/grafana/latest/alerting/configure-notifications/template-notifications/

If this isn't enough we can consider creating a feature request to have this value in the default template similar to Slack.

williancolognesitrimble commented 3 months ago

This change is likely caused by the automatic upgrade to Unified Alerting in 9.x. It should be possible to template the direct link to the alert by using the {{ .GeneratorURL }} field of an individual alert. Something like:

I'm talking about the button that's currently hardcoded in Google Chat receiver https://github.com/grafana/alerting/blob/main/receivers/googlechat/googlechat.go#L67

The workaround to put a link in the alert message is ok, but having a way to customize the button url would be better (to keep the previous behaviour)