postgresml/pgcat

Duplicate metrics HELP and TYPE lines

Opened this issue · 0 comments

Describe the bug
The Prometheus endpoint might return duplicate HELP and TYPE lines when configured with multiple pools. This causes issues with telegraf accessing those metrics:

[inputs.prometheus] Error in plugin: error reading metrics for "http://localhost:9930/metrics": reading text format failed: text format parsing error in line 61: second HELP line for metric name "pgcat_stats_total_xact_count"

To Reproduce
Steps to reproduce the behavior:

  1. Configure pgcat with two pools
  2. Enable prometheus exported
  3. Access the metrics endpoint
  4. Verify that HELP and TYPE lines are only shown once per metric.

Current behavior

# HELP pgcat_stats_total_xact_count Total number of transactions started by the client
# TYPE pgcat_stats_total_xact_count counter
pgcat_stats_total_xact_count{role="primary",host="localhost",database="db1",pool="db1",shard="0"} 500

[...]

# HELP pgcat_stats_total_xact_count Total number of transactions started by the client
# TYPE pgcat_stats_total_xact_count counter
pgcat_stats_total_xact_count{role="primary",host="localhost",database="db2",pool="db2",shard="0"} 250

Expected behavior

# HELP pgcat_stats_total_xact_count Total number of transactions started by the client
# TYPE pgcat_stats_total_xact_count counter
pgcat_stats_total_xact_count{role="primary",host="localhost",database="db1",pool="db1",shard="0"} 500

[...]

pgcat_stats_total_xact_count{role="primary",host="localhost",database="db2",pool="db2",shard="0"} 250

Environment
os: Ubuntu 22.04.3 LTS
pgcat: 1.1.2-dev
postgresql: 15.4