Grafana Alerts with Graphite

I’m running Grafana 9.3.1 with Graphite as a backend using Docker.

With this version, the alert add/edit screen has changed a bit. Now a new label is created called “name” with the metric I am building the alert on.


In the Graphite function, I am using “aliasByNode(5)” to show the instance number of this particular service. But the “name” in the expression is the full series name. Is there a way to have the expression only show the output of the “aliasByNode” and use that as the “name”?

I am using the “name” label in the “Summary and annotations” to highlight the metric with the alert.
grafana.2
I’ve tried the Go template functions available to try and parse the “name” label, but the available functions are very limited.

I think I found my answer from another post in the Graphite group. I was trying to use “reReplaceAll” not understanding that I could parse the metric and only return the field I want.

         |---1-----|------2----|---3---|------4----|-----5---------|---6---|
METRIC : production.application.service.server_name.name_of_service.instance

Use the below to pull the individual metric

Field 2
{{ reReplaceAll "^production\\.([^.]+).*" "$1" $labels.name }}
Returns : application

Field 3
{{ reReplaceAll "^production\\.[^.]+\\.([^.]+).*" "$1" $labels.name }}
Returns : service

Field 4
{{ reReplaceAll "^production\\.[^.]+\\.[^.]+\\.([^.]+).*" "$1" $labels.name }}
Returns : server_name

Field 5
{{ reReplaceAll "^production\\.[^.]+\\.[^.]+\\.[^.]+\\.([^.]+).*" "$1" $labels.name }}
Returns : name_of_service

Field 6
{{ reReplaceAll "^production\\.[^.]+\\.[^.]+\\.[^.]+\\.[^.]+\\.([^.]+).*" "$1" $labels.name }}
Returns : instance

So the field you want should be ([^.]+).* after using [^.]+\\. for the field you want to skip.