Commit Graph

134 Commits

Author SHA1 Message Date
Alex Craig
2fd6762d7f
Merge 04e73d413c into 6526065fbc 2025-04-22 21:27:50 -04: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
vancwo
2869087f3c
Fix: Handle incoming labels with invalid UTF-8 (#1131)
It's possible that incoming labels will contain invalid UTF-8 characters. This results in a panic. This fix sanitizes the label's string to ensure only valid UTF-8 characters are included, by replacing invalid characters with � (REPLACEMENT CHARACTER)

Signed-off-by: Cooper Worobetz <cooper@worobetz.ca>
2025-02-26 14:21:39 +01:00
Joe Adams
4c170ed564
Fix missing dsn sanitization for logging (#1104)
This log line was not sanitized previously which could result in logging sensitive information. I have scanned the rest of the files and I don't see anywhere else that DSN is used in a log line without this filter.

Resolves #1042

Signed-off-by: Joe Adams <github@joeadams.io>
2025-02-15 16:35:04 +01:00
Felipe Galindo Sanchez
2ee2a8fa7c
feat: add wait/backend to pg_stat_activity (#1106)
Signed-off-by: Felipe Galindo Sanchez <felipe.galindo.sanchez@intel.com>
2025-02-15 09:08:24 -05:00
aagarwalla-fx
5bb1702321
Fix to replace dashes with underscore in the metric names (#1103)
* Fix to replace dashes with underscore in the metric names

Signed-off-by: aagarwalla-fx <arpit.agarwalla@falconx.io>

* Code style fix

Signed-off-by: aagarwalla-fx <arpit.agarwalla@falconx.io>

---------

Signed-off-by: aagarwalla-fx <arpit.agarwalla@falconx.io>
2024-12-22 16:14:19 -05: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
Steffen Zieger
98f75c7e7e
stop logging errors on replicas, fixes #547 (#1048)
Signed-off-by: Steffen Zieger <github@saz.sh>
2024-09-05 09:28:31 -04:00
Keegan Carruthers-Smith
f98834a678
use Info level for excluded databases log message (#1003)
This is the only log message which didn't specify a level in the
postgres_exporter. I am unsure if this log message should be info or
debug, but leaning towards the more important since previously it would
just always log.

The way I validated this was the only non-leveled logger was via grep.
Both of these only returned this callsite previously:

  git grep 'logger\.Log'
  git grep '\.Log(' | grep -v level

Signed-off-by: Keegan Carruthers-Smith <keegan.csmith@gmail.com>
2024-02-14 13:38:27 -05:00
dependabot[bot]
69fc35b0ec
Bump github.com/prometheus/client_golang from 1.16.0 to 1.17.0 (#925)
* Bump github.com/prometheus/client_golang from 1.16.0 to 1.17.0

Bumps [github.com/prometheus/client_golang](https://github.com/prometheus/client_golang) from 1.16.0 to 1.17.0.
- [Release notes](https://github.com/prometheus/client_golang/releases)
- [Changelog](https://github.com/prometheus/client_golang/blob/main/CHANGELOG.md)
- [Commits](https://github.com/prometheus/client_golang/compare/v1.16.0...v1.17.0)

---
updated-dependencies:
- dependency-name: github.com/prometheus/client_golang
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>

* Update tests for latest client_golang.

Signed-off-by: SuperQ <superq@gmail.com>

---------

Signed-off-by: dependabot[bot] <support@github.com>
Signed-off-by: SuperQ <superq@gmail.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Co-authored-by: SuperQ <superq@gmail.com>
2023-10-02 16:00:41 +02:00
Joe Adams
30d7d25a7e
Add error log when probe collector creation fails (#918)
Signed-off-by: Joe Adams <github@joeadams.io>
2023-09-21 07:13:14 -04:00
Eric Tyrrell
e3eaa91c0b
Adds 1kB and 2kB units (#915)
Signed-off-by: Eric tyrrell <eric.tyrrell18+github@gmail.com>
2023-09-19 21:40:29 -04: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
Alex Tymchuk
b070e45349
chore: fix a few typos
Signed-off-by: Alex Tymchuk <alexander.tymchuk@percona.com>
2023-06-23 16:42:59 +03:00
SuperQ
c71d395bf6
Deprecate additional database features
Now that we have deprecated extended queries we can deprecate related
database features.
* Deprecate flags/functions around auto discover databases.
* Deprecate flags/functions for additional constant labels.

Signed-off-by: SuperQ <superq@gmail.com>
2023-06-19 13:05:57 +02:00
Ben Kochie
7dcf1dc7b6
Deprecate extend queries feature (#811)
Mark the extend queries feature as deprecated in favor of recommending
the sql_exporter.

Signed-off-by: SuperQ <superq@gmail.com>
2023-06-13 17:39:39 +02:00
Joe Adams
4d41f89f0c
Merge pull request #685 from sysadmind/pg-stat-database
Convert pg_stat_database to new collector model
2023-06-12 19:25:46 -04:00
SuperQ
fab8e625a8
Update linting
* Move errcheck exclude list to config file.
* Enable revive linter
* Fix up revive linting issues.

Signed-off-by: SuperQ <superq@gmail.com>
2023-06-03 09:28:17 +02:00
Jack Wink
0c04fc1d1e
Supports alternate postgres:// prefix in URLs
Adds support for the alternate postgres:// prefix in URLs. It's maybe
not the cleanest approach, but works.  Hoping I can either get some
pointers on a more appropriate patch, or that we could use this in the
interim to unblock this use-case.

Signed-off-by: Jack Wink <57678801+mothershipper@users.noreply.github.com>
2023-04-24 09:17:05 -07:00
Khaled Khalifa
20b1b75e64
Fix pg_setting different help values
Signed-off-by: GitHub <noreply@github.com>
2023-04-16 11:29:12 +00:00
Joe Adams
ac05e0bdce
Adjust log level for collector startup
Since we support both multi-target and typical direct scrapes, either of these can fail and it is no longer an error.

Signed-off-by: Joe Adams <github@joeadams.io>
2023-03-29 20:15:41 -04:00
SuperQ
de1c3cc5e7
Update exporter-toolkit
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>
2023-03-21 08:23:23 +01:00
SuperQ
0e654d8f83
Update build
* Update Go to 1.20.
* Update golanci-lint.
* Bump modules.
* Update CI orb.
* Fix up use of deprecated ioutil.

Signed-off-by: SuperQ <superq@gmail.com>
2023-03-05 22:20:50 +01:00
Joe Adams
55263868e0
Remove more dead code
Signed-off-by: Joe Adams <github@joeadams.io>
2023-03-05 15:30:18 -05:00
Joe Adams
8d6ce0558c Remove commented code
Signed-off-by: Joe Adams <github@joeadams.io>
2023-03-05 15:18:23 -05:00
Joe Adams
799f3e15b2 Fix exclude-databases for collector package
The pg_database collector was not respecting the --exclude-databases flag and causing problems where databases were not accessible. This now respects the list of databases to exclude.

- Adjusts the Collector create func to take a config struct instead of a logger. This allows more changes like this in the future. I figured we would need to do this at some point but I wasn't sure if we could hold off.
- Split the database size collection to a separate query when database is not excluded.
- Comment some probe code that was not useful/accurate

Signed-off-by: Joe Adams <github@joeadams.io>
2023-03-05 15:13:00 -05:00
Joe Adams
36773e06dc
Merge pull request #673 from cezmunsta/pg_stat_activity-enhancements
Capture usename and application_name for pg_stat_activity
2023-02-12 15:08:39 -05:00
Joe Adams
94a89b0166
Merge pull request #734 from kjbass/master
Close DB connection after probe completes.
2023-02-12 14:52:50 -05:00
Ben Kochie
0e4506e3f4
Merge pull request #746 from prometheus-community/bjk/exporter-toolkit-bump
Update exporter-toolkit
2023-01-25 09:31:55 +01:00
SuperQ
b1e72a981b
go fmt
Signed-off-by: SuperQ <superq@gmail.com>
2023-01-24 18:18:17 +01:00
SuperQ
fc264d0ab0
Update exporter-toolkit
Update to the latest exporter-toolkit
* Enables multi-listener and systemd socket activation.
* Bump Go to 1.19.
* Remove `PG_EXPORTER_WEB_LISTEN_ADDRESS` env var because this is now a
  repeatable flag.

Signed-off-by: SuperQ <superq@gmail.com>
2023-01-24 17:57:31 +01:00
Oleksandr Mysyura
8ff0e5aa70 New unit value 64kB
Signed-off-by: Oleksandr Mysyura <olexandr.mysyura@pragmaticplay.com>
2023-01-04 12:14:29 +02:00
Kurtis Bass
76223cdda8 probe: clean-up database connection after probe to prevent connection leak
Signed-off-by: Kurtis Bass <kurtis.bass@hinge.co>
2022-12-14 14:30:13 -05:00
Julien Pivotto
5fcceb4105 Set gauge to 1 when collector is successful
Signed-off-by: Julien Pivotto <roidelapluie@o11y.eu>
2022-11-24 14:02:37 +01:00
Joe Adams
34d3605788
Merge pull request #683 from preved911/fix/extend_probe_path_metrics
Extending /probe path metrics
2022-10-31 20:51:30 -04:00
Sergey Morozov
14c9d0370f
4kB size added for postgres with 4kB block_size
Signed-off-by: Sergey Morozov <38383507+ken3122@users.noreply.github.com>
2022-10-09 01:50:45 +06:00
cezmunsta
d9ac4be429
Fixed formatting
Signed-off-by: cezmunsta <github@incoming-email.co.uk>
2022-10-04 13:18:22 +01:00
cezmunsta
6937685907
Capture usename and application_name for pg_stat_activity
It is necessary to be able to exclude backups from long-running
transaction alerts, as they are to be expected. With the current
pg_stat_activity metric there is no ability to filter out
specific users or application names.

Resolves #668

Signed-off-by: cezmunsta <github@incoming-email.co.uk>
2022-10-04 13:18:22 +01:00
Ildar Valiullin
ad8b5608f8 extended /probe path metrics
Signed-off-by: Ildar Valiullin <preved.911@gmail.com>
2022-09-03 14:33:13 +03:00
Joe Adams
73b0b42c8d
Convert pg_stat_database to new collector model
Signed-off-by: Joe Adams <github@joeadams.io>
2022-09-02 12:24:25 -04:00
Joe Adams
7ffba684de
Update multi-target handler to use new DSN type
- Moves new dsn type to config.DSN. This will prevent circular dependencies.
- Change DSN.query to be url.Values. This allows the multi-target functionality to merge values without re-parsing the query string
- Change NewProbeCollector to use the new config.DSN type
- Add DSN.GetConnectionString to return a string formatted for the sql driver to use during connection

Signed-off-by: Joe Adams <github@joeadams.io>
2022-09-02 10:32:44 -04:00
Yoan Blanc
9ae347519b
fix: typo
Signed-off-by: Yoan Blanc <yoan@dosimple.ch>
2022-08-30 06:48:06 +02:00
SuperQ
d86dd06ffe
Release 0.12.0-rc.0
BREAKING CHANGES:

This release changes support for multiple postgres servers to use the
multi-target exporter pattern. This makes it much easier to monitor multiple
PostgreSQL servers from a single exporter by passing the target via URL
params. See the Multi-Target Support section of the README.

* [CHANGE] Add multi-target support #618
* [BUGFIX] Add dsn type for handling datasources #678

Signed-off-by: SuperQ <superq@gmail.com>
2022-08-26 16:49:54 +02:00
Joe Adams
de9d21df6a
Add dsn type for handling datasources
dsn is designed to replace the other uses of dsn as a string in the long term. dsn is designed to be safe to log, properly redacting passwords. The goal is eventually always parse datasource information into a dsn type object which can safely be passed around and logged without worrying about wrapping calls in a redaction function (today this function is loggableDSN().

This should solve the root issue in #648, #677, and #643, although the full fix will require more changes to update all code references over to use the dsn type.

Signed-off-by: Joe Adams <github@joeadams.io>
2022-08-24 22:07:37 -04:00
AlexDHoffer
04e73d413c Sanitize url for printing when given password passed as parameter
Signed-off-by: AlexDHoffer <alexdchoffer@gmail.com>
2022-08-18 16:34:31 -07:00
Joe Adams
72430f8d2a Update cmd/postgres_exporter/main.go
Signed-off-by: Joe Adams <github@joeadams.io>
2022-07-28 10:21:02 -04:00
Joe Adams
8f8d2208f5 cleanup and README
Signed-off-by: Joe Adams <github@joeadams.io>

Co-authored-by: Ben Kochie <superq@gmail.com>
2022-07-28 10:19:32 -04:00
Joe Adams
cc751b7966 Add config module
The config module supports adding configuration to the exporter via a config file. This supports adding authentication details in a config file so that /probe requests can specify authentication for endpoints

Signed-off-by: Joe Adams <github@joeadams.io>
2022-07-28 10:19:32 -04:00
Joe Adams
713461df98 WIP: Add prelim multi-target support
- Remove multi server support from new collector package
- Add http handler for multi-target support

Signed-off-by: Joe Adams <github@joeadams.io>
2022-07-28 10:19:32 -04:00
SuperQ
81c4933986
Update build
* Update to Go 1.18.
* Update minimum Go version to 1.17.
* Update Go modules for 1.17 format.
* Bump Go modules
* Enable dependabot.
* Update Prometheus common files.
* Fixup yamllint.

Signed-off-by: SuperQ <superq@gmail.com>
2022-05-25 11:27:42 +02:00