1
0
mirror of https://github.com/prometheus-community/postgres_exporter.git synced 2025-08-06 17:22:43 +03:00

refactor pg_stat_bgwriter metrics into standalone collector

This moves the metrics that are queried from pg_stat_bgwriter into a dedicated collector instead of dynamically generating queries and metrics from a map. It renames some metrics including adding the `_total` suffix on all of the counters to match prometheus standards. This implementation uses QueryRowContext to allow for later addition of context for cancellation. From the Postgres documentation, it states that there is one line per WAL sender process, but it is unclear how to differentiate between them in any meaningful way. When querying the table, there is no column to identify the row, only metrics about bgwriter.

Signed-off-by: Joe Adams <github@joeadams.io>
This commit is contained in:
Joe Adams
2021-07-06 22:07:23 -04:00
parent 35b53f7889
commit 27d23d02ef
8 changed files with 280 additions and 41 deletions

View File

@@ -584,7 +584,7 @@
{
"alias": "Buffers Allocated",
"dsType": "prometheus",
"expr": "irate(pg_stat_bgwriter_buffers_alloc{instance='$instance'}[5m])",
"expr": "irate(pg_stat_bgwriter_buffers_alloc_total{instance='$instance'}[5m])",
"format": "time_series",
"groupBy": [
{
@@ -636,7 +636,7 @@
{
"alias": "Buffers Allocated",
"dsType": "prometheus",
"expr": "irate(pg_stat_bgwriter_buffers_backend_fsync{instance='$instance'}[5m])",
"expr": "irate(pg_stat_bgwriter_buffers_backend_fsync_total{instance='$instance'}[5m])",
"format": "time_series",
"groupBy": [
{
@@ -688,7 +688,7 @@
{
"alias": "Buffers Allocated",
"dsType": "prometheus",
"expr": "irate(pg_stat_bgwriter_buffers_backend{instance='$instance'}[5m])",
"expr": "irate(pg_stat_bgwriter_buffers_backend_total{instance='$instance'}[5m])",
"format": "time_series",
"groupBy": [
{
@@ -740,7 +740,7 @@
{
"alias": "Buffers Allocated",
"dsType": "prometheus",
"expr": "irate(pg_stat_bgwriter_buffers_clean{instance='$instance'}[5m])",
"expr": "irate(pg_stat_bgwriter_buffers_clean_total{instance='$instance'}[5m])",
"format": "time_series",
"groupBy": [
{
@@ -792,7 +792,7 @@
{
"alias": "Buffers Allocated",
"dsType": "prometheus",
"expr": "irate(pg_stat_bgwriter_buffers_checkpoint{instance='$instance'}[5m])",
"expr": "irate(pg_stat_bgwriter_buffers_checkpoint_total{instance='$instance'}[5m])",
"format": "time_series",
"groupBy": [
{