pg_exporter_last_scrape_duration_seconds - kubernetes_namespace

50 views
Skip to first unread message

Tamar

unread,
Nov 1, 2020, 5:06:22 AM11/1/20
to Prometheus Users
Hi,

I used a prepared Grafana dashboard for postgres, using postgres_exporter.
In it I can see that the first varialbe is this query fron prometheus data source:

Query:   query_result(pg_exporter_last_scrape_duration_seconds)
Regex: /.*kubernetes_namespace="([^"]+).*/

I have no kubernetes cluster configured, so I expect Prometheus is using it somehow?

What is the meaning of this?

Thanks,
Tamar

Brian Candler

unread,
Nov 1, 2020, 8:41:36 AM11/1/20
to Prometheus Users
I expect it's for a drop-down menu in the dashboard.

If your pg_exporter_last_scrape_duration_seconds metric doesn't have any label "kubernetes_namespace", then that Grafana query isn't going to find any values for that dropdown.

But if the variable has an empty value, then any dashboard query of the form
    pg_whatever{kubernetes_namespace="$namespace"}
will match all metrics with {kubernetes_namespace=""}, which is the same as metrics without a "kubernetes_namespace" label.

Tamar

unread,
Nov 1, 2020, 9:43:33 AM11/1/20
to Prometheus Users

Hi,

Thank you for that answer!

I actually have 3 variables:
NameSpace:
Query: query_result(pg_exporter_last_scrape_duration_seconds)
Regexp: /.*kubernetes_namespace="([^"]+).*/

Release:
Query: query_result(pg_exporter_last_scrape_duration_seconds{kubernetes_namespace="$namespace"})
Regex: /.*release="([^"]+)/

Instance:
Query: query_result(up{release="$release",job="postgres_exporter"})
Regex: /.*instance="([^"]+).*/

I need to add another variable to reflect different ports on the same server(host)
In prometheus metrics it looks like this for example:

pg_settings_seq_page_cost{instance="10.97.7.97:9187",job="postgres_exporter",server="10.97.7.97:5009"}
pg_settings_seq_page_cost{instance="10.97.7.97:9187",job="postgres_exporter",server="10.97.7.97:5020"}

So how can I define a variable to give me a drop down list of servers with ports, or add it to the "instance" varabiable?

Thanks,
Tamar


ב-יום ראשון, 1 בנובמבר 2020 בשעה 15:41:36 UTC+2, b.ca...@pobox.com כתב/ה:

Brian Candler

unread,
Nov 1, 2020, 11:25:05 AM11/1/20
to Prometheus Users
This is really a grafana question, not a prometheus question.  You can make a new variable in exactly the same way as the "instance" one to capture the "server" label:

Instance:
Query: query_result(pg_settings_seq_page_cost{instance="$instance",job="postgres_exporter"})
Regex: /.*server="([^"]+).*/

If necessary, replace pg_settings_seq_page_cost with some metric that you expect to see as part of *every* postgres instance scrape.

Tamar

unread,
Nov 2, 2020, 7:54:22 AM11/2/20
to Prometheus Users
Thank you

ב-יום ראשון, 1 בנובמבר 2020 בשעה 18:25:05 UTC+2, b.ca...@pobox.com כתב/ה:
Reply all
Reply to author
Forward
0 new messages