prometheus + reusable templates

156 views
Skip to first unread message

Luís Martins

unread,
Feb 14, 2022, 10:19:36 AM2/14/22
to Prometheus Users
Hi all, I'm currently struggling to use reusable templates on Prometheus alert annotation descriptions.

I'm using prometheus docker image and I've set a custom path in "--web.console.libraries" (e.g. "/path/to/libraries/")
I defined a file (e.g. "/path/to/libraries/alert-mytemplate.lib") with a template:
    {{ define "mytemplate" }}
    ...
    {{ end }}
And added this on some alerts annotations:
    description: "{{ template \"mytemplate\" (args ...) }}"
However in runtime I still get the error that the template is not found whenever the alert is triggered:
    template \"mytemplate\" not defined
I'm trying to follow the instructions in [1][2] but I'm currently blocked, can anyone understand what is it missing here?

[1] https://prometheus.io/docs/prometheus/latest/configuration/template_examples/#defining-reusable-templates
[2] https://prometheus.io/docs/prometheus/latest/configuration/template_reference/#console-templates

Yann “Stratanic” .mabilat

unread,
Nov 25, 2023, 1:48:16 PM11/25/23
to Prometheus Users

same here I try use template,

in last version prometheus
Reply all
Reply to author
Forward
0 new messages