Skip to content

Commit

Permalink
Merge pull request #8 from bitglue/pgbouncer_1_9
Browse files Browse the repository at this point in the history
Support new metrics in pgbouncer 1.8
  • Loading branch information
Marco Pracucci authored Dec 5, 2018
2 parents 7aa9996 + 327ca0e commit 3a59533
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 6 deletions.
8 changes: 6 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -46,10 +46,14 @@ The exporter exports the following metrics for each monitored pgbouncer instance

| Metric name | Type | Description |
| -------------------------------------------------- | -------- | ---------------- |
| `pgbouncer_stats_queries_total` | counter | Total number of SQL queries pooled by pgbouncer (labels: `database`) |
| `pgbouncer_stats_queries_duration_microseconds` | counter | Total number of microseconds spent by pgbouncer when actively connected to PostgreSQL (labels: `database`) |
| `pgbouncer_stats_requests_total` | counter | Total number of requests pooled. Could be transactions or queries, depending on pool mode. (labels: `database`, pgbouncer < 1.8) |
| `pgbouncer_stats_queries_total` | counter | Total number of SQL queries pooled by pgbouncer (labels: `database`, pgbouncer >= 1.8) |
| `pgbouncer_stats_queries_duration_microseconds` | counter | Total number of microseconds spent waiting for a server to return a query response. Includes time spent waiting for an available connection. (labels: `database`, pgbouncer >= 1.8) |
| `pgbouncer_stats_waiting_duration_microseconds` | counter | Total number of microseconds spent waiting for an available connection. (labels: `database`, pgbouncer >= 1.8) |
| `pgbouncer_stats_received_bytes_total` | counter | Total volume in bytes of network traffic received by pgbouncer (labels: `database`) |
| `pgbouncer_stats_sent_bytes_total` | counter | Total volume in bytes of network traffic sent by pgbouncer (labels: `database`) |
| `pgbouncer_stats_transactions_total` | counter | Total number of SQL transactions pooled by pgbouncer (labels: `database`, pgbouncer >= 1.8) |
| `pgbouncer_stats_transactions_duration_microseconds`| counter | Total number of microseconds spent in a transaction. Includes time spent waiting for an available connection. (labels: `database`, pgbouncer >= 1.8) |
| `pgbouncer_pools_client_active_connections` | gauge | Client connections that are linked to server connection and can process queries (labels: `database`, `user`) |
| `pgbouncer_pools_client_waiting_connections` | gauge | Client connections have sent queries but have not yet got a server connection (labels: `database`, `user`) |
| `pgbouncer_pools_server_active_connections` | gauge | Server connections that linked to client (labels: `database`, `user`) |
Expand Down
18 changes: 14 additions & 4 deletions prometheus_pgbouncer_exporter/collector.py
Original file line number Diff line number Diff line change
Expand Up @@ -54,10 +54,20 @@ def collect(self):
results = self._filterMetricsByIncludeDatabases(results, self.config.getIncludeDatabases())
results = self._filterMetricsByExcludeDatabases(results, self.config.getExcludeDatabases())
metrics += self._exportMetrics(results, "pgbouncer_stats_", [
{"type": "counter", "column": "total_requests", "metric": "queries_total", "help": "Total number of SQL queries pooled by pgbouncer"},
{"type": "counter", "column": "total_query_time", "metric": "queries_duration_microseconds", "help": "Total number of microseconds spent by pgbouncer when actively connected to PostgreSQL"},
{"type": "counter", "column": "total_received", "metric": "received_bytes_total", "help": "Total volume in bytes of network traffic received by pgbouncer"},
{"type": "counter", "column": "total_sent", "metric": "sent_bytes_total", "help": "Total volume in bytes of network traffic sent by pgbouncer"},
# pgbouncer < 1.8
{"type": "counter", "column": "total_requests", "metric": "requests_total", "help": "Total number of requests pooled. Could be transactions or queries, depending on pool mode."},

# pgbouncer >= 1.8
{"type": "counter", "column": "total_xact_count", "metric": "transactions_total", "help": "Total number of transactions pooled"},
{"type": "counter", "column": "total_query_count", "metric": "queries_total", "help": "Total number of queries pooled"},
{"type": "counter", "column": "total_xact_time", "metric": "transactions_duration_microseconds", "help": "Total number of microseconds spent in a transaction. Includes time spent waiting for an available connection."},
{"type": "counter", "column": "total_query_time", "metric": "queries_duration_microseconds", "help": "Total number of microseconds spent waiting for a server to return a query response. Includes time spent waiting for an available connection."},
{"type": "counter", "column": "total_wait_time", "metric": "waiting_duration_microseconds", "help": "Total number of microseconds spent waiting for an available connection."},

# all versions
{"type": "counter", "column": "total_received", "metric": "received_bytes_total", "help": "Total volume in bytes of network traffic received by pgbouncer"},
{"type": "counter", "column": "total_sent", "metric": "sent_bytes_total", "help": "Total volume in bytes of network traffic sent by pgbouncer"},

], {"database": "database"}, self.config.getExtraLabels())
else:
success = False
Expand Down

0 comments on commit 3a59533

Please sign in to comment.