Cristian Greco
06a553c816
Ensure database connections are always closed ( #1177 )
...
Signed-off-by: Sam DeHaan <sam.dehaan@grafana.com >
Signed-off-by: Sam DeHaan <dehaansa@gmail.com >
Co-authored-by: Sam DeHaan <sam.dehaan@grafana.com >
Co-authored-by: Sam DeHaan <dehaansa@gmail.com >
2025-07-18 14:53:45 -04:00
Cristian Greco
dfde566f2a
chore: fix a typo and use slices.Contains
( #1176 )
...
Minor fixes as I was skimming through:
- fix typo in `stat_statements`
- drop custom `sliceContains` in `database`
Signed-off-by: Cristian Greco <cristian@regolo.cc >
2025-07-11 09:31:12 +02:00
Peter Nuttall
d8ba628b1e
Add a collector for pg_buffercache_summary
. ( #1165 )
...
* Add a collector for pg_buffercache_summary()
* Requires PostgreSQL >= 16.
---------
Signed-off-by: Peter Nuttall <peter.nuttall@snowflake.com >
Co-authored-by: Ben Kochie <superq@gmail.com >
2025-06-19 07:33:22 +02:00
Jakub Štiller
de42ef7de8
Export query itself together with queryId in stat_statement metrics ( #940 )
...
* Export query itself together with queryId in stat_statement metrics
* The feature must be enabled via flag.
* Limit length of selected query.
The query is not added to every metrics, but instead of new metric stat_statement_query_id is introduced that contains mapping between queryId and query.
Fixes : #813
---------
Signed-off-by: Jakub Štiller <stiller@2n.cz >
Signed-off-by: Jakub Štiller <jakstiller@atlas.cz >
2025-05-16 10:50:19 +02:00
Felix Yuan
5edc331876
Record table only size bytes as well in addition to the total size bytes ( #1149 )
...
* Record table only size bytes as well in addition to the total size bytes
Signed-off-by: Felix Yuan <felix.yuan@reddit.com >
* Update collector/pg_stat_user_tables.go
Co-authored-by: Ben Kochie <superq@gmail.com >
Signed-off-by: Felix Yuan <felix.yuan@reddit.com >
* Update collector/pg_stat_user_tables.go
Co-authored-by: Ben Kochie <superq@gmail.com >
Signed-off-by: Felix Yuan <felix.yuan@reddit.com >
* Finish renaming elements to index and table size
Signed-off-by: Felix Yuan <felix.yuan@reddit.com >
---------
Signed-off-by: Felix Yuan <felix.yuan@reddit.com >
Co-authored-by: Ben Kochie <superq@gmail.com >
2025-04-18 16:14:25 +02:00
Ben Kochie
8d5ec4b3ea
Update Go ( #1147 )
...
* Update Go to 1.24.
* Update golangci-lint to v2.
* Fixup linting issues.
Signed-off-by: SuperQ <superq@gmail.com >
2025-04-03 17:23:40 +02:00
Ian Bibby
9e86f1ee38
Adds pg_stat_progress_vacuum collector ( #1141 )
...
Signed-off-by: Ian Bibby <ian.bibby@reddit.com >
Co-authored-by: Ben Kochie <superq@gmail.com >
2025-04-03 16:45:29 +02:00
Nicolas Rodriguez
8bb1a41abf
Skip pg_stat_checkpointer collector if pg<17 ( #1112 )
...
* fix: skip collector if pg<17
Signed-off-by: Michael Todorovic <michael.todorovic@outlook.com >
* fix: better condition
Signed-off-by: Michael Todorovic <michael.todorovic@outlook.com >
* fix: fix PGStatCheckpointerCollector tests
Signed-off-by: Nicolas Rodriguez <nico@nicoladmin.fr >
---------
Signed-off-by: Michael Todorovic <michael.todorovic@outlook.com >
Signed-off-by: Nicolas Rodriguez <nico@nicoladmin.fr >
Co-authored-by: Michael Todorovic <michael.todorovic@outlook.com >
2025-02-19 21:49:11 -05:00
Conrad Hoffmann
c3885e840a
Export last replay age in replication collector ( #1085 )
...
The exported replication lag does not handle all failure modes, and can
report 0 for replicas that are out of sync and incapable of recovery.
A proper replacement for that metric would require a different approach
(see e.g. #1007 ), but for a lot of folks, simply exporting the age of
the last replay can provide a pretty strong signal for something being
amiss.
I think this solution might be preferable to #977 , though the lag
metric needs to be fixed or abandoned eventually.
Signed-off-by: Conrad Hoffmann <ch@bitfehler.net >
2025-02-15 09:15:44 -05:00
Michael Todorovic
9e42fc0145
fix: handle pg_replication_slots on pg<13 ( #1098 )
...
* fix: handle pg_replication_slots on pg<13
Signed-off-by: Michael Todorovic <michael.todorovic@outlook.com >
* fix: tests
Signed-off-by: Michael Todorovic <michael.todorovic@outlook.com >
---------
Signed-off-by: Michael Todorovic <michael.todorovic@outlook.com >
2025-02-15 09:00:48 -05:00
Nevermind
072864d179
pg_stat_statements PG17 ( #1114 )
...
Signed-off-by: Nevermind <79126473+NevermindZ4@users.noreply.github.com >
2025-02-15 08:54:12 -05:00
Nicolas Rodriguez
bea2609519
Checkpoint related columns in PG 17 have been moved from pg_stat_bgwriter to pg_stat_checkpointer ( #1072 )
...
* Checkpoint related columns in PG 17 have been moved from pg_stat_bgwriter to pg_stat_checkpointer
Fix https://github.com/prometheus-community/postgres_exporter/issues/1060
See: https://www.dbi-services.com/blog/postgresql-17-new-catalog-view-pg_stat_checkpointer/
Signed-off-by: Nicolas Rodriguez <nico@nicoladmin.fr >
* Add support for pg_stat_checkpointer
See: https://www.dbi-services.com/blog/postgresql-17-new-catalog-view-pg_stat_checkpointer/
Signed-off-by: Nicolas Rodriguez <nico@nicoladmin.fr >
* Run integration tests with Postgres 17
Signed-off-by: Nicolas Rodriguez <nico@nicoladmin.fr >
* Update date in file header
Signed-off-by: Nicolas Rodriguez <nico@nicoladmin.fr >
---------
Signed-off-by: Nicolas Rodriguez <nico@nicoladmin.fr >
2025-01-01 16:03:43 -05:00
Jyothi Kiran Thammana
6f36adfadf
Update pg_long_running_transactions.go ( #1092 )
...
To extract time in seconds for pg_long_running_transactions_oldest_timestamp_seconds query which currently return epoch time.
Signed-off-by: Jyothi Kiran Thammana <147131742+jyothikirant-sayukth@users.noreply.github.com >
2024-12-22 15:09:35 -05:00
Conrad Hoffmann
552ff92f8b
Make walreceiver collector useful w/o repmgr ( #1086 )
...
In a streaming replication setup that was created without replication
manager (`repmgr`), the `stat_wal_receiver` collector does not return
any metrics, because one value it wants to export is not present.
This is rather overly opinionated. The missing metric is comparatively
uninteresting and does not justify discarding all the others. And
replication setups created without `repmgr` are not exactly rare.
This commit makes the one relevant metric optional and simply skips it
if the respective value cannot be determined.
Signed-off-by: Conrad Hoffmann <ch@bitfehler.net >
2024-11-06 18:47:30 +01:00
TJ Hoplock
e8540767e4
chore!: adopt log/slog, drop go-kit/log ( #1073 )
...
* ci: update go to version 1.23
Signed-off-by: TJ Hoplock <t.hoplock@gmail.com >
* build(deps): bump prometheus/{client_golang,common,exporter-toolkit}
Signed-off-by: TJ Hoplock <t.hoplock@gmail.com >
* chore!: adopt log/slog, drop go-kit/log
The bulk of this change set was automated by the following script which
is being used to aid in converting the various exporters/projects to use
slog:
https://gist.github.com/tjhop/49f96fb7ebbe55b12deee0b0312d8434
Signed-off-by: TJ Hoplock <t.hoplock@gmail.com >
---------
Signed-off-by: TJ Hoplock <t.hoplock@gmail.com >
Co-authored-by: Ben Kochie <superq@gmail.com >
2024-10-26 21:44:17 +02:00
Marc W
49f66e1bfb
fix: Only query active_time on pg>=14 ( #1045 )
...
Signed-off-by: MarcWort <113890636+MarcWort@users.noreply.github.com >
2024-06-25 09:15:21 -04:00
Marc W
a4ac0e6747
feat: Add safe_wal_size and wal_status to replication_slot ( #1027 )
...
* feat: Add safe_wal_size to replication_slot
Signed-off-by: MarcWort <113890636+MarcWort@users.noreply.github.com >
* feat: Add wal_status to replication_slot
Signed-off-by: MarcWort <113890636+MarcWort@users.noreply.github.com >
---------
Signed-off-by: MarcWort <113890636+MarcWort@users.noreply.github.com >
2024-05-11 14:59:55 +02:00
Jocelyn Thode
8f39f5b114
Add connection limits metrics for pg_roles and pg_database ( #997 )
...
* Add database connection limits metrics
Signed-off-by: Jocelyn Thode <jocelyn@thode.email >
* Add roles connection limits metrics
Signed-off-by: Jocelyn Thode <jocelyn@thode.email >
* Fix copyright year
Co-authored-by: Joe Adams <github@joeadams.io >
Signed-off-by: Jocelyn Thode <jocelynthode@users.noreply.github.com >
* Fix spacing in pgDatabaseQuery
Co-authored-by: Joe Adams <github@joeadams.io >
Signed-off-by: Jocelyn Thode <jocelynthode@users.noreply.github.com >
* Fix case on pgRolesConnectionLimitsQuery
Co-authored-by: Joe Adams <github@joeadams.io >
Signed-off-by: Jocelyn Thode <jocelynthode@users.noreply.github.com >
* Do not add roleMetrics when row is not valid
Signed-off-by: Jocelyn Thode <jocelyn@thode.email >
---------
Signed-off-by: Jocelyn Thode <jocelyn@thode.email >
Signed-off-by: Jocelyn Thode <jocelynthode@users.noreply.github.com >
Co-authored-by: Joe Adams <github@joeadams.io >
2024-02-21 21:10:17 -05:00
Jiri Sveceny
f5b613aba7
pg_stat_database: added support for active_time
counter ( #961 )
...
* feat(pg_stat_database): active time metric
---------
Signed-off-by: Jiri Sveceny <jiri.sveceny@icloud.com >
2023-11-28 15:12:07 +01:00
Alex Simenduev
ae1375b28e
pg_replication_slot: add slot type label ( #960 )
...
Signed-off-by: Alex Simenduev <shamil.si@gmail.com >
2023-11-23 09:44:58 +01:00
Joe Adams
2a5692c028
Adjust collector to use separate connection per scrape ( #931 )
...
Fixes #921
Signed-off-by: Joe Adams <github@joeadams.io >
2023-10-10 07:07:37 -04:00
Daniel Swarbrick
51415a0e5b
Fix test build failures on 32-bit arch again ( #919 )
...
Another case of untyped integer overflows on 32-bit arch.
Signed-off-by: Daniel Swarbrick <daniel.swarbrick@gmail.com >
2023-09-21 14:58:46 +02:00
Joe Adams
4e521d460e
Fix bugs mentioned in #908 ( #910 )
...
* Fix bugs mentioned in #908
These collectors are disabled by default, so unless enabled, they are not tested regularly.
Signed-off-by: Joe Adams <github@joeadams.io >
---------
Signed-off-by: Joe Adams <github@joeadams.io >
2023-09-13 09:19:21 -04:00
David Cook
31ef4ed5a2
stat_user_tables: Add total size metric ( #904 )
...
Signed-off-by: David Cook <dcook@divviup.org >
2023-09-12 09:07:36 -04:00
Vladimir Luksha
0b6d9860ab
fix pg_replication_lag_seconds ( #895 )
...
Signed-off-by: Vladimir Luksha <waldemarluksha@gmail.com >
Co-authored-by: Vladimir Luksha <luksha@limcore.io >
2023-09-08 16:20:19 -04:00
Christian Albrecht
68ea167866
Fix a connection leak ( #902 )
...
The leak was introduced in PR#882
Signed-off-by: Christian Albrecht <cal@albix.de >
Co-authored-by: Christian Albrecht <christian.albrecht@akquinet.de >
2023-09-05 22:07:37 -04:00
Felix Yuan
5890879126
Gitlab Collector: Long running transactions collector and test ( #836 )
...
* Long running transactions collector and test
---------
Signed-off-by: Felix Yuan <felix.yuan@reddit.com >
Co-authored-by: Ben Kochie <superq@gmail.com >
2023-08-25 11:20:10 +02:00
Felix Yuan
ce74daee92
Gitlab Collector: User Index io stats collector and test ( #845 )
...
* User Index io stats collector and test
---------
Signed-off-by: Felix Yuan <felix.yuan@reddit.com >
2023-08-24 09:55:26 +02:00
Felix Yuan
2402783205
Bugfix: Make statsreset nullable ( #877 )
...
* Stats_reset as null seems to actually be legitimate for new databases,
so don't fail for it
---------
Signed-off-by: Felix Yuan <felix.yuan@reddit.com >
Co-authored-by: Ben Kochie <superq@gmail.com >
2023-08-24 09:51:26 +02:00
Joe Adams
b74852a535
Delay database connection until scrape ( #882 )
...
This no longer returns an error when creating a collector.instance when the database cannot be reached for the version query. This will resolve the entire postgresCollector not being registered for metrics collection when a database is not available. If the version query fails, the scrape will fail.
Resolves #880
Signed-off-by: Joe Adams <github@joeadams.io >
2023-08-23 17:33:47 -04:00
Ben Kochie
716ac23f20
Fixup new pg_stats_statements query ( #876 )
...
Fix all renames of `total_time` to `total_exec_time`.
Fixes: https://github.com/prometheus-community/postgres_exporter/issues/502
Signed-off-by: SuperQ <superq@gmail.com >
2023-07-25 22:36:51 +02:00
Ben Kochie
f9277b04b7
Handle new pg_stat_statements column names ( #874 )
...
Update pg_stat_statements collector to handle the new column names in
PostgreSQL 13.
Fixes: https://github.com/prometheus-community/postgres_exporter/issues/502
Signed-off-by: SuperQ <superq@gmail.com >
2023-07-25 16:20:37 +02:00
Felix Yuan
74800f483a
Gitlab collector: Xlog location collector and test ( #849 )
...
* Xlog location collector and test
Signed-off-by: Felix Yuan <felix.yuan@reddit.com >
* Add more escapes
Signed-off-by: Felix Yuan <felix.yuan@reddit.com >
* Change to Gauge
Signed-off-by: Felix Yuan <felix.yuan@reddit.com >
---------
Signed-off-by: Felix Yuan <felix.yuan@reddit.com >
2023-07-21 14:42:43 -04:00
Felix Yuan
2d7e152751
Gitlab Collector: Wal Receiver Collector and Test ( #844 )
...
* Wal Receiver Collector and Test
Signed-off-by: Felix Yuan <felix.yuan@reddit.com >
* Add more escapes
Signed-off-by: Felix Yuan <felix.yuan@reddit.com >
* Corrections to wal_receiver
Signed-off-by: Felix Yuan <felix.yuan@reddit.com >
* Continue on null labels
Signed-off-by: Felix Yuan <felix.yuan@reddit.com >
* Skip nulls and log a message
Signed-off-by: Felix Yuan <felix.yuan@reddit.com >
* Redundant breaks
Signed-off-by: Felix Yuan <felix.yuan@reddit.com >
* Fix up walreceiver
Signed-off-by: Felix Yuan <felix.yuan@reddit.com >
* Remove extra label
Signed-off-by: Felix Yuan <felix.yuan@reddit.com >
* Update collector/pg_stat_walreceiver.go
Co-authored-by: Ben Kochie <superq@gmail.com >
Signed-off-by: Felix Yuan <felix.yuan@reddit.com >
* Clean up the extra assignments
Signed-off-by: Felix Yuan <felix.yuan@reddit.com >
* Update collector/pg_stat_walreceiver.go
Co-authored-by: Joe Adams <github@joeadams.io >
Signed-off-by: Felix Yuan <felix.yuan@reddit.com >
---------
Signed-off-by: Felix Yuan <felix.yuan@reddit.com >
Co-authored-by: Ben Kochie <superq@gmail.com >
Co-authored-by: Joe Adams <github@joeadams.io >
2023-07-21 14:42:08 -04:00
Felix Yuan
dc3e813f43
Gitlab Collector: Autovacuum collector and test ( #840 )
...
* Autovacuum collector and test
Signed-off-by: Felix Yuan <felix.yuan@reddit.com >
* Update collector/pg_stat_activity_autovacuum.go
Co-authored-by: Joe Adams <github@joeadams.io >
Signed-off-by: Felix Yuan <felix.yuan@reddit.com >
* Update collector/pg_stat_activity_autovacuum.go
Co-authored-by: Joe Adams <github@joeadams.io >
Signed-off-by: Felix Yuan <felix.yuan@reddit.com >
* Use timestamp seconds
Signed-off-by: Felix Yuan <felix.yuan@reddit.com >
* query formating
Signed-off-by: Felix Yuan <felix.yuan@reddit.com >
* SQL format
Signed-off-by: Felix Yuan <felix.yuan@reddit.com >
* Loosen autovacuum query
Signed-off-by: Felix Yuan <felix.yuan@reddit.com >
---------
Signed-off-by: Felix Yuan <felix.yuan@reddit.com >
Co-authored-by: Joe Adams <github@joeadams.io >
2023-07-21 14:41:25 -04:00
Felix Yuan
12c12cf368
Add a logger to stat_database collector to get better handle on error
...
(also clean up some metric validity checks)
Signed-off-by: Felix Yuan <felix.yuan@reddit.com >
2023-07-19 14:26:41 -07:00
Felix Yuan
4aa8cd4996
Gitlab collector: Database wraparound collector and test ( #834 )
...
* Database wraparound collector and test
---------
Signed-off-by: Felix Yuan <felix.yuan@reddit.com >
Co-authored-by: Joe Adams <github@joeadams.io >
2023-07-14 22:42:12 +02:00
Joe Adams
4ac5481917
Merge pull request #862 from tomhughes/idle-state
...
Include all idle processes in the process idle metrics
2023-07-06 19:58:39 -04:00
Ben Kochie
5f917ccdd9
Improve linting ( #861 )
...
* Disable unused-parameter check due to false positives on Collect()
calls.
* Enable misspell.
* Simplify error returns.
Signed-off-by: SuperQ <superq@gmail.com >
2023-07-06 13:08:45 +02:00
Tom Hughes
a8b86cf7da
Include all idle processes in the process idle metrics
...
Signed-off-by: Tom Hughes <tom@compton.nu >
2023-07-06 08:48:59 +01:00
Tom Hughes
6b56e2f057
Unpack postgres arrays for process idle times correctly ( #855 )
...
Signed-off-by: Ben Kochie <superq@gmail.com >
2023-07-06 09:33:54 +02:00
Daniel Swarbrick
2477aba363
Fix untyped integer overflows on 32-bit archs ( #857 )
...
go-sqlmock's Rows.AddRow() takes values which have a type alias of
"any", and appear to default to untyped ints if not explicitly cast.
When large values are passed which would overflow int32, tests fail.
Signed-off-by: Daniel Swarbrick <daniel.swarbrick@gmail.com >
2023-07-05 15:10:47 +02:00
Tom Hughes
2ca1798188
Add a collector to gather metrics on WAL size
...
Signed-off-by: Tom Hughes <tom@compton.nu >
2023-07-05 11:51:57 +01:00
Tom Hughes
099d3ddb6f
Add some more escapes to the query sanitizer
...
Signed-off-by: Tom Hughes <tom@compton.nu >
2023-07-04 19:08:35 +01:00
Tom Hughes
d920553227
Fix replication collector
...
Signed-off-by: Tom Hughes <tom@compton.nu >
2023-07-03 17:51:50 +01:00
Felix Yuan
e6ce2ecba9
Bug Fix: Fix lingering type issues ( #828 )
...
* Fix postmaster type issue
* Disable postmaster collector by default
---------
Signed-off-by: Felix Yuan <felix.yuan@reddit.com >
2023-06-27 20:18:02 +02:00
Ben Kochie
030a2a9bc7
Cleanup collectors ( #826 )
...
Fix up `replication` and `process_idle` Update input params to match
the rest of the collectors.
Signed-off-by: SuperQ <superq@gmail.com >
2023-06-27 16:40:12 +02:00
Ben Kochie
1a4e8993f6
Migrate pg_locks to collector package ( #817 )
...
Migrate the `pg_locks_count` query from `main` to the `collector`
package.
Signed-off-by: SuperQ <superq@gmail.com >
2023-06-27 15:59:30 +02:00
Vadim Voitenko
6a1bb59efb
Fixed replication pgReplicationSlotQuery - now it's working correctly for replica and primary ( #825 )
...
Signed-off-by: Vadim Voitenko <vadim.voitenko@exness.com >
Co-authored-by: Vadim Voitenko <vadim.voitenko@exness.com >
2023-06-27 15:47:33 +02:00
Felix Yuan
8d087f2c64
Bug fix: Make collector not fail on null values ( #823 )
...
* Make all values nullable
---------
Signed-off-by: Felix Yuan <felix.yuan@reddit.com >
Co-authored-by: Ben Kochie <superq@gmail.com >
2023-06-27 08:07:59 +02:00