Skip to content

Commit

Permalink
Fixed tests after introduction of pgbouncer 1.8 support and improved …
Browse files Browse the repository at this point in the history
…README
  • Loading branch information
Marco Pracucci committed Dec 5, 2018
1 parent 3a59533 commit 0fb5d22
Show file tree
Hide file tree
Showing 4 changed files with 189 additions and 42 deletions.
7 changes: 7 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,12 @@
# Changelog

- [BREAKING CHANGE] Renamed `pgbouncer_stats_queries_total` to `pgbouncer_stats_requests_total` on pgbouncer <= 1.7
- [FEATURE] Added pgbouncer >= 1.8 support [#8](https://github.com/spreaker/prometheus-pgbouncer-exporter/pull/8) (thanks to [bitglue](https://github.com/bitglue)), including the following new metrics:
- `pgbouncer_stats_transactions_total`
- `pgbouncer_stats_queries_total`
- `pgbouncer_stats_transactions_duration_microseconds`
- `pgbouncer_stats_waiting_duration_microseconds`

### 1.0.1 (2018-08-30)
- [BUGFIX] Fixed `PGBOUNCER_EXPORTER_PORT` environment variable data type [#7](https://github.com/spreaker/prometheus-pgbouncer-exporter/pull/7)

Expand Down
43 changes: 22 additions & 21 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -44,27 +44,28 @@ PgBouncer is a single thread application and so can only saturate a single CPU c

The exporter exports the following metrics for each monitored pgbouncer instance:

| Metric name | Type | Description |
| -------------------------------------------------- | -------- | ---------------- |
| `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`) |
| `pgbouncer_pools_server_idle_connections` | gauge | Server connections that unused and immediately usable for client queries (labels: `database`, `user`) |
| `pgbouncer_pools_server_used_connections` | gauge | Server connections that have been idle more than server_check_delay, so they needs server_check_query to run on it before it can be used (labels: `database`, `user`) |
| `pgbouncer_pools_server_testing_connections` | gauge | Server connections that are currently running either server_reset_query or server_check_query (labels: `database`, `user`) |
| `pgbouncer_pools_server_login_connections` | gauge | Server connections currently in logging in process (labels: `database`, `user`) |
| `pgbouncer_pools_client_maxwait_seconds` | gauge | How long the first (oldest) client in queue has waited, in seconds (labels: `database`, `user`) |
| `pgbouncer_databases_database_pool_size` | gauge | Configured pool size limit (labels: `database`, `backend_database`) |
| `pgbouncer_databases_database_reserve_pool_size` | gauge | Configured reserve limit (labels: `database`, `backend_database`) |
| `pgbouncer_databases_database_current_connections` | gauge | Total number of per-database Database connections count (labels: `database`, `backend_database`) |
| Metric name | Type | PgBouncer | Description |
| --------------------------------------------------- | -------- | --------- | ---------------- |
| `pgbouncer_stats_requests_total` | counter | _<= 1.7_ | Total number of requests pooled. Could be transactions or queries, depending on pool mode. (labels: `database`) |
| `pgbouncer_stats_queries_total` | counter | _>= 1.8_ | Total number of SQL queries pooled by pgbouncer (labels: `database`) |
| `pgbouncer_stats_queries_duration_microseconds` | counter | _all_ | 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_stats_waiting_duration_microseconds` | counter | _>= 1.8_ | Total number of microseconds spent waiting for an available connection. (labels: `database`) |
| `pgbouncer_stats_received_bytes_total` | counter | _all_ | Total volume in bytes of network traffic received by pgbouncer (labels: `database`) |
| `pgbouncer_stats_sent_bytes_total` | counter | _all_ | Total volume in bytes of network traffic sent by pgbouncer (labels: `database`) |
| `pgbouncer_stats_transactions_total` | counter | _>= 1.8_ | Total number of SQL transactions pooled by pgbouncer (labels: `database`) |
| `pgbouncer_stats_transactions_duration_microseconds`| counter | _>= 1.8_ | Total number of microseconds spent in a transaction. Includes time spent waiting for an available connection. (labels: `database`) |
| `pgbouncer_pools_client_active_connections` | gauge | _all_ | Client connections that are linked to server connection and can process queries (labels: `database`, `user`) |
| `pgbouncer_pools_client_waiting_connections` | gauge | _all_ | Client connections have sent queries but have not yet got a server connection (labels: `database`, `user`) |
| `pgbouncer_pools_server_active_connections` | gauge | _all_ | Server connections that linked to client (labels: `database`, `user`) |
| `pgbouncer_pools_server_idle_connections` | gauge | _all_ | Server connections that unused and immediately usable for client queries (labels: `database`, `user`) |
| `pgbouncer_pools_server_used_connections` | gauge | _all_ | Server connections that have been idle more than server_check_delay, so they needs server_check_query to run on it before it can be used (labels: `database`, `user`) |
| `pgbouncer_pools_server_testing_connections` | gauge | _all_ | Server connections that are currently running either server_reset_query or server_check_query (labels: `database`, `user`) |
| `pgbouncer_pools_server_login_connections` | gauge | _all_ | Server connections currently in logging in process (labels: `database`, `user`) |
| `pgbouncer_pools_client_maxwait_seconds` | gauge | _all_ | How long the first (oldest) client in queue has waited, in seconds (labels: `database`, `user`) |
| `pgbouncer_databases_database_pool_size` | gauge | _all_ | Configured pool size limit (labels: `database`, `backend_database`) |
| `pgbouncer_databases_database_reserve_pool_size` | gauge | _all_ | Configured reserve limit (labels: `database`, `backend_database`) |
| `pgbouncer_databases_database_current_connections` | gauge | _all_ | Total number of per-database Database connections count (labels: `database`, `backend_database`) |


## Configuration file

Expand Down
8 changes: 4 additions & 4 deletions prometheus_pgbouncer_exporter/collector.py
Original file line number Diff line number Diff line change
Expand Up @@ -55,18 +55,18 @@ def collect(self):
results = self._filterMetricsByExcludeDatabases(results, self.config.getExcludeDatabases())
metrics += self._exportMetrics(results, "pgbouncer_stats_", [
# 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."},
{"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"},
{"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_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:
Expand Down
Loading

0 comments on commit 0fb5d22

Please sign in to comment.