Prometheus config job template


I have a template with prometheus configuration and it uses $labels from prometheus.
Using this with the artifact+template stanza to deploy a job gives me an error parsing this kind of variables. Is there a way to force the template stanza to parse all the iles as raw?


Hi Bruno, could you paste the error message and a simple of example of how to reproduce your problem?

Can you reproduce this just using the template stanza with the data property e.g.:

template {
 data = <<EOH
   bind_port:   {{ env "NOMAD_PORT_db" }}
   scratch_dir: {{ env "NOMAD_TASK_DIR" }}
   node_id:     {{ env "" }}
   service_key: {{ key "service/my-key" }}

 destination = "local/file.yml"

Hi Raphael, thanks for the reply.

$labels are internal to prometheus, it’s no an env var.
I’ve managed to use it like this:

{{ “{{” }} $labels {{ “}}” }} inside the template. This way the consul template parses this without messing with the internal $labels var.