pFad - Phone/Frame/Anonymizer/Declutterfier! Saves Data!


--- a PPN by Garber Painting Akron. With Image Size Reduction included!

URL: http://github.com/prometheus-community/postgres_exporter/wiki

el="stylesheet" href="https://github.githubassets.com/assets/primer-b69241e157469407.css" /> Home · prometheus-community/postgres_exporter Wiki · GitHub
Skip to content
Jonathan Mackenzie edited this page Oct 11, 2023 · 6 revisions

Welcome to the postgres_exporter wiki!

Sample queries for Grafana from postgres_exporter that might be useful:

You will want to update to your filters (inside {}).

# of connections: pg_stat_database_numbackends{job="prodpg-exporter"}

# of locks (by lock type) for a specific DB: pg_locks_count{job="prodpg-exporter",datname="MYDB"}
legend_format: {{mode}}

Cache hit rate by database: rate(pg_stat_database_blks_hit{job="prodpg-exporter"}[5m])
legend_format: {{datname}}

disk reads per sec by database: rate(pg_stat_database_blks_read{instance="proddb"}[5m])
legend_format: {{datname}}

Custom Queries

You can have the exporter run custom queries by setting the PG_EXPORTER_EXTEND_QUERY_PATH environment variable and pointing it to a .yaml file.

When specifying queries.yml, use the following format as defined here:

https://github.com/prometheus-community/postgres_exporter/blob/2a5692c0283fddf96e776cc73c2fc0d5caed1af6/cmd/postgres_exporter/queries.go#L26-L32

metric_name:
  master: true # (optional)
  cache_seconds: 30 # (optional)
  query: "SELECT metric_1, metric_2 FROM table"
  metrics:
    - metric_1:
        usage: "LABEL"
        description: "Metric 1 description"
    - metric_2:
        usage: "GAUGE"
        description: "Metric 2 description"

Metrics use the format defined here: https://github.com/prometheus-community/postgres_exporter/blob/2a5692c0283fddf96e776cc73c2fc0d5caed1af6/cmd/postgres_exporter/postgres_exporter.go#L69C1-L75

  • usage: string
  • description: string
  • metric_mapping: map[string]float64, Optional column mapping for MAPPEDMETRIC
  • pg_version: Semantic version ranges which are supported. Unsupported columns are not queried (internally converted to DISCARD).

Usage must be one of these values: https://github.com/prometheus-community/postgres_exporter/blob/2a5692c0283fddf96e776cc73c2fc0d5caed1af6/cmd/postgres_exporter/postgres_exporter.go#L32-L51

  • DISCARD ignores a column
  • LABEL identifies a column as a label
  • COUNTER identifies a column as a counter
  • GAUGE identifies a column as a gauge
  • MAPPEDMETRIC identifies a column as a mapping of text values
  • DURATION identifies a column as a text duration (and converted to milliseconds)
  • HISTOGRAM identifies a column as a histogram

Clone this wiki locally

pFad - Phonifier reborn

Pfad - The Proxy pFad © 2024 Your Company Name. All rights reserved.





Check this box to remove all script contents from the fetched content.



Check this box to remove all images from the fetched content.


Check this box to remove all CSS styles from the fetched content.


Check this box to keep images inefficiently compressed and original size.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy