I am trying community version Grafana 9.4.7 and working with Alerts and need to parse $value which is a string.
I need to perform string operations such as replace a string with another and so on.
Grafana templates what functions can be used? The only one i could use was slice. But functions like split, replace etc doesn’t seem to be available for me.
Hi @kmarrrahul, we recently updated the documentation for the latest Grafana version:
- String functions from Go’s template language such as
sliceorurlquery. - String functions for alert rule templates
{{ title "hello, world!" }}
{{ toUpper "Hello, world!" }}
{{ toLower "Hello, world!" }}
{{ stripPort "example.com:8080" }}
{{ match "a.*" "abc" }}
{{ reReplaceAll "localhost:(.*)" "example.com:$1" "localhost:8080" }}
{{ stripDomain "example.com:8080" }}
{{ graphLink "{\"expr\": \"up\", \"datasource\": \"gdev-prometheus\"}" }}
{{ parseDuration "1h" }}
{{ title "hello, world!" }}
{{ toUpper "Hello, world!" }}
{{ toLower "Hello, world!" }}
{{ trimSpace "Hello, world!" }}
{{ match "a.*" "abc" }}
{{ reReplaceAll "localhost:(.*)" "example.com:$1" "localhost:8080" }}
{{ join "-" (stringSlice "a" "b" "c") }}
{{ safeHtml "<b>Text</b>"}}
{{ stringSlice "a" "b" "c" }}
Hope it helps!