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>
* 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>
* 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>
* Long running transactions collector and test
---------
Signed-off-by: Felix Yuan <felix.yuan@reddit.com>
Co-authored-by: Ben Kochie <superq@gmail.com>
* 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>
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>
* 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>
* 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>
* 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>
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>
The intent is to use the instance struct to hold the connection to the database as well as metadata about the instance. Currently this metadata only includes the version of postgres for the instance which can be used in the collectors to decide what query to run. In the future this could hold more metadata but for now it keeps the Collector interface arguments to a reasonable number.
Signed-off-by: Joe Adams <github@joeadams.io>
Use const definitions to make collector registration consistent.
* Use collector subsystem name consistently.
* Fix up replication metric name unit.
Signed-off-by: SuperQ <superq@gmail.com>
The signature for creating a collector changed and CI didn't retrigger. Move metrics out of map and into individual vars.
Signed-off-by: Joe Adams <github@joeadams.io>
Updates the exporter-toolkit to the latest version
* Adds new landing page feature.
* Allow metrics path to be on `/`.
Signed-off-by: SuperQ <superq@gmail.com>