Alert templates question? .ValueString not working?

Running 9.0.2 and experimenting with alerting templates with the following simple example:

{{ define "test" }}
{{ .ValueString }}
{{ end }}

in the email contact point message i have:

{{ template "test" .}}

when firing an alert or even the test alert i get just an empty alert:

does valuestring work like this? as i need to trim and extract sections eventually.

heres a sample from a non templated alert showing the string i need :

Value: [ var=‘B0’ metric=‘RMF’ labels={description=% eappl (total) by job, label=DBB, resource=ABC,*,PROCESSOR} value=156.2 ]

I wold like to display

label=DBB
resource=ABC,*,PROCESSOR
value=156.2

maybe a timestamp if possible?

Thanks

@mrdibbley welcome to the :grafana: community!

I created a detailed example for this in a response to this post, I hope it’s helpful!

Wow that is awesome and a lot easier. Can you still use reReplaceAll and regex to tweak the labels in AlertValues ?

I tried a simple:

{{ with .Status }} reReplaceAll “.*” “fred” . }} {{ end }}

but it just printed Alert summary:

1 firing: reReplaceAll “.*” “fred” . }}

treating it a text

Thanks

HI Melori,
seen your post i am alos looking for the same solution can u please help me with same

Value: [ var=‘B0’ metric=‘RMF’ labels={description=% eappl (total) by job, label=DBB, resource=ABC,*,PROCESSOR} value=156.2 ]

I wold like to display

label=DBB
resource=ABC,*,PROCESSOR
value=156.2

@mrdibbley yes, these should still work! There’s an example here:

Hey @melori.arellano ,

I am using the Grafana Oncall template and in that getting value string in
“valueString”: “[ var=‘B0’ metric=‘Deploy-QA-MAIN-1 (GH)’ labels={} value=1 ]”,
this way ,
As grafana Oncall using the Jinja 2 template can u please help me to print
this value in list format Like below
metric=‘Deploy-QA-MAIN-1 (GH)’
value=1

@maheshmane since this is for Grafana OnCall - I did a little research for you and wondered if this post in our oncall github repo was also yours: Grafana Oncall templates new helper filter regex_replace() · Issue #226 · grafana/oncall · GitHub

That github repository is where the docs direct community members looking for help with on-call templates. If you have a cloud subscription, support may also be able to help you with this one.