From 6edbc4604cbffe7a2ae565da724dc352ae9d0974 Mon Sep 17 00:00:00 2001 From: And^Cw Howden Date: Sun, 15 Jan 2017 20:56:53 +0100 Subject: [PATCH 1/2] Add additional documentation about Prometheus + Templated queries --- docs/sources/datasources/prometheus.md | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/docs/sources/datasources/prometheus.md b/docs/sources/datasources/prometheus.md index fd14d0539e7..cdeb6c500b1 100644 --- a/docs/sources/datasources/prometheus.md +++ b/docs/sources/datasources/prometheus.md @@ -72,4 +72,8 @@ label_values(hostname) You can also use raw queries & regular expressions to extract anything you might need. +### Using templated variables in queries + +When the `Include All` option or `Multi-Value` option is enabled, Grafana converts the labels from plain text to a regex compatible string. If your labels include special values such as `.` or `/`, you will need to use the `=~` or regex match in your Prometheus query. For example, a query for ALERTS, a template query of `label(ALERTS,instance)` and an instance value of `http://example.com` would become `ALERTS{instance=~$instance}` instead of `ALERTS{instance=$instance}`. + ![](/img/v2/prometheus_templating.png) From 2fdb47ae9758aedc9b84323dfa42b8aa394372a0 Mon Sep 17 00:00:00 2001 From: bergquist Date: Mon, 16 Jan 2017 11:50:12 +0100 Subject: [PATCH 2/2] docs(prometheus): rewrote and shorten the note about templates --- docs/sources/features/datasources/prometheus.md | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/docs/sources/features/datasources/prometheus.md b/docs/sources/features/datasources/prometheus.md index cdeb6c500b1..2a35bb615cb 100644 --- a/docs/sources/features/datasources/prometheus.md +++ b/docs/sources/features/datasources/prometheus.md @@ -74,6 +74,7 @@ You can also use raw queries & regular expressions to extract anything you might ### Using templated variables in queries -When the `Include All` option or `Multi-Value` option is enabled, Grafana converts the labels from plain text to a regex compatible string. If your labels include special values such as `.` or `/`, you will need to use the `=~` or regex match in your Prometheus query. For example, a query for ALERTS, a template query of `label(ALERTS,instance)` and an instance value of `http://example.com` would become `ALERTS{instance=~$instance}` instead of `ALERTS{instance=$instance}`. +When the `Include All` option or `Multi-Value` option is enabled, Grafana converts the labels from plain text to a regex compatible string. +Which means you have to use `=~` instead of `=` in your Prometheus queries. For example `ALERTS{instance=~$instance}` instead of `ALERTS{instance=$instance}`. ![](/img/v2/prometheus_templating.png)