Grafana alert notification message templating

Hi Team,

I’m using Grafana 9.1.5 and Google Cloud Monitoring data source.
I’ve created alert for CPU usage of specific processes (a few java applications). i want to avoid creating separate alert for each of them.
So, one of metric label is Linux process command line, for example:

java -Defg.instance.id=efgproduscentral2-l11m -Djava.security.egd=file:/dev/./urandom -Dlog4j2.formatMsgNoLookups=LOG4J_FORMAT_MSG_NO_LOOKUPS -Xmx1g -Dcom.sun.jndi.ldap.object.disableEndpointIdentification=true -Dspring.config.location=/apps/test-aaa.properties -jar /apps/test-aaa.jar

java -Xmx2g -Dh2.bindAddress=127.0.0.1 -cp /apps/test-bbb.jar org.h2.tools.Server -tcp -ifNotExists

I want to use applications names in alert notification Summary.

Question:
Is it possible (using templating functions) to extract from above:
test-aaa
test-bbb
or maybe use conditions like:
if label value is like “test-aaa” then print “App AAA”
if label value is like “test-bbb” then print “App BBB”

Thanks in advance !

Ged

Resolved. Looks simple when you now :slight_smile:

$labels.app label stores command line of process in my case

{{ if (match “.test-aaa.” $labels.app) }}
App AAA
{{ else if (match “.tes-bbb.” $labels.app) }}
App BBB
{{ end }}

Maybe it will help someone in the future :slight_smile:

Ged