Variable substitution in Prometheus yaml file Variable substitution in Prometheus yaml file kubernetes kubernetes

Variable substitution in Prometheus yaml file


UPDATE:

Looks like Thanos gives this out of the box.We have to configure Thanos to watch for the config file which has this templated variables and produce the output to a directory. And Prometheus then picks this file as its config file. This file would have the "substituted values" already from Thanos sidecar.


There is a standard way to do it after Prometheus 2.27.

See disabled_features

--enable-feature=expand-external-labels

Replace ${var} or $var in the external_labels values according to the values of the current environment variables. References to undefined variables are replaced by the empty string.

And this reply by roidelaplui