Commit Graph

436 Commits

Author SHA1 Message Date
Don Petersen
f870f9591b
Don't ignore errors in parseUserQueries (#362)
Failures in parsing the user's queries are just being swallowed, which
makes troubleshooting YAML issues frustrating/impossible. I'm presuming
this was not intentional, since there is error handling code in the
function that calls this one, though it is unreachable as far as I can
tell without this change.

Co-authored-by: Will Rouesnel <wrouesnel@wrouesnel.com>
2020-02-25 22:56:49 +11:00
rafis
0c4425c4b3
Fix max connection alerts formulas (#368) 2020-02-25 22:56:18 +11:00
Ben Kochie
aeec47ead4 Add a build info metric (#323)
* Add a build info metric

Add a standard Prometheus build info metric to make monitoring rollouts
easier.

* Update prometheus vendoring.

* Fix build error

Fix missing bool in builtinMetricMaps.

Signed-off-by: Ben Kochie <superq@gmail.com>
2019-11-26 00:16:23 +11:00
Will Rouesnel
03013dea2e
Re-add pg_stat_bgwriter metrics which were accidentally removed.
During a refactor the pg_stat_bgwriter metrics were accidentally removed
and not re-added by 34fdb69ee2.

This commit restores these metrics. Resolves #336.
2019-11-26 00:01:36 +11:00
Will Rouesnel
54a0cf0e63
Fix build error introduced by pg_archiver metrics bad merge.
2772da8dbe was missing an additional
parameter. This fixes the build.
2019-11-25 23:50:43 +11:00
Russ Garrett
2772da8dbe Export pg_stat_archiver metrics
These are useful for knowing if WAL archiving is working successfully.
2019-11-20 10:21:50 +11:00
Vladimir N. Indik
75d542d496 Update "Flags" list in README (#331)
* Update README according --help output

* Update environment variables list in README
2019-11-20 10:19:34 +11:00
sfalkon
c4508ff430 Refactoring: fix error 2019-11-20 10:18:20 +11:00
sfalkon
d74818ccac fix integration test 2019-11-20 10:18:20 +11:00
sfalkon
deac1c37db fix master database behavior 2019-11-20 10:18:20 +11:00
Benjamin P. Jung
9b13f5ec57 Add support for 'DATA_SOURCE_URI_FILE' envvar.
Closes #326 as is provides a viable solution to use a K8S init container
to fully contruct the PostgreSQL URI and 'hand it over' to the postgres_exporter
process.
2019-11-20 10:17:31 +11:00
Will Rouesnel
852ec5d9a1 Add example.alerts.yml
Adds a file containing some basic alerting rules for Prometheus as a launch point for more community contributions (or just when
I get around to coming up with some more I'm interested in).
2019-11-01 10:11:18 +11:00
Will Rouesnel
03457ae745
Stop including tools/src in source tarballs.
Fixes #239.
2019-11-01 01:18:05 +11:00
Will Rouesnel
c2866fd2e2
Fix README.md. 2019-11-01 01:04:08 +11:00
Will Rouesnel
bb0870c562 Rename pg_database_size to pg_database_size_bytes 2019-11-01 00:29:32 +11:00
Will Rouesnel
698fdb7873 Add pg_stat_statements to sample queries.yml file. 2019-11-01 00:29:32 +11:00
Will Rouesnel
34fdb69ee2
Add support for optional namespace caching. (#319)
In the user queries.yml file, the created namespaces can now be optionally
cached by setting cache_seconds, which will prevent the query being re-run
within that timeframe if previous results are available.

Supercedes #211, credit to @SamSaffron for the original PR.
2019-11-01 00:17:31 +11:00
sfalkon
1385b4f658 Fix some autodiscovery problems (#314)
* Fix problem: If autodiscovery is enable exporter make connection twice to database from connetion string (exclude current database from SQL-query);

* Fix problem: don't get default metrics and settings if autodiscovery is enabled. Now you can use --disable-default-metrics and --disable-settings-metrics with --auto-discover-databases and
2019-10-31 22:09:30 +11:00
Alexis Sellier
ececfdeab7 Yaml parsing refactor (#299)
* Use struct instead of interface{} when parsing query user

* Use MappingOptions

* Split function to be more testable

* Rename function to parseUserQueries

* Start to add test about query parsing
2019-10-31 22:07:59 +11:00
Daniel Pintara
e1428a8330 Don't stop generating fingerprint while encountering value with "=" sign (#318) 2019-10-31 22:02:27 +11:00
Marcos A L M Macedo
27d5c9926d Add SQL for grant connect (#303)
To resolve the error below, it was necessary to add a new grant to the database postgres.

Error: 'pq: permission denied for database \ "postgres \"'
2019-10-30 14:58:17 +11:00
Michael Kaye
d6f7ff1641 Expose pg_current_wal_lsn_bytes (#307) 2019-10-30 14:57:54 +11:00
Leo Antunes
e362f444aa [minor] fix landing page content-type (#305) 2019-10-30 14:57:12 +11:00
Johan Karlberg
69a90e8a33 Updated lib/pg driver to 1.2.0 in order to support stronger SCRAM-SHA-256 authentication. This drops support for Go < 1.11 and PostgreSQL < 9.4. (#304) 2019-10-30 14:56:38 +11:00
Wolfgang Schnerring
b33c2f9349 Provide more helpful default values for tables that have never been vacuumed (#310)
Returning a (long gone) timestamp does the right thing for alerting
PromQL queries ("alert if older than"), while `NaN` is rather intractable.
2019-10-30 14:55:48 +11:00
Dan Molik
043e68e067 Add retries to getServer() (#316)
Some backstory
==============

I was attempting to use postgres_exporter with the official Docker
container (https://hub.docker.com/_/postgres) In a Kubernetes
StatefulSet, with a side-car configuration, but found that I wasn't able
to connect even with sharing the Postgres Unix listening socket, between
both containers. After copying the container over to an Alpine base I
quickly found out that the postgres_exporter was actually starting
before the main Postres container had dropped the unix socket onto the
file system, a quick work around is to write a bash for loop checking
for the existence of a unix socket, however this would require
maintaining a container, besides other users may find retries useful on
startup.

Implementation
==============

All changes are made to the getServer function and variables are
local, I was unsure if it was worth adding command line switches but
this would allow for a more sophisticated backOff loop in the future.

Hope this help, and let me know if you would like me to changes
anything.
2019-10-30 14:54:18 +11:00
Dmitry Ulyanov
238f5c099a Fix pg_up metric returns last calculated value without explicit resetting (#291)
If exporter is scraped by multiple Prometheuses (as we do) - Collect() could be called concurrently. In result in some cases one of Prometheuses could get pg_up = 0, because it was explicitly set to zero on first Collect call.
2019-08-12 13:35:58 +10:00
Alexis Sellier
1ab8d2bbc8 Discover only databases that are not templates and allow connections (#297)
* Discover only databases that are not templates and allow connections

* Update readme
2019-08-12 11:40:58 +10:00
Alexis Sellier
c768e64548 Add --exclude-databases option (#298)
* Add exclude-databases option
* Update readme to explain --exclude-databases
* Add comments to ExcludeDatabases function and unexport Contains function
2019-08-12 11:25:01 +10:00
Richard Kojedzinszky
5f3a711ebd Use application_name column as a label 2019-07-12 10:26:33 +10:00
Sakis
1c14eb964a README: SQL that supports re-execution
Make the SQL work in automated deployments where it will be repeated many times.
2019-07-12 10:26:07 +10:00
Will Rouesnel
0d7891de1a
Fix smoke-tests to more reliably use pg_isready. 2019-07-03 23:14:20 +10:00
Will Rouesnel
bb8b37cbeb
Revert "Updated the magefile.go to use new version of archiver library"
This reverts commit 6585e6672f.

There's been some weird changes added to the upstream archiver library which
break the build. Since this is only used in the build process, I'm in no hurry
to update it.
2019-07-03 22:44:24 +10:00
Will Rouesnel
97554928e6
Update README.md 2019-07-03 22:37:58 +10:00
Will Rouesnel
7b2dc3f2a4
Update travis secrets. 2019-07-03 22:37:58 +10:00
Kerim Djiho
6585e6672f Updated the magefile.go to use new version of archiver library 2019-07-03 22:25:08 +10:00
Janis Orlovs
06781103f0 Docker file added multistage build to add non-root user running under ID:20001 for image.
Reduces attack surface by not running image as root user
2019-07-03 22:17:37 +10:00
Arno Geurts
85c31524f6 Fix build for auto-discover-databases feature 2019-07-03 22:17:15 +10:00
Arno Geurts
4d96104c10 Add documentation for auto-discover-databases 2019-07-03 22:17:15 +10:00
Arno Geurts
58043f72da Add option to automatically discover database names 2019-07-03 22:17:15 +10:00
Miguel Hernandez
2b896ea2df add support for boolean data types as metrics
This is useful if your database uses true/false for state and want to make prometheus alerts based on that.
Before, booleans were not able to be parsed.  See issue #201
2019-07-01 08:44:56 +10:00
Rick van Hattem
486345d8fd No need to truncate replication lag to integers 2019-07-01 08:44:04 +10:00
Alexey Palazhchenko
84a575f29f Group and sort imports. 2019-07-01 08:43:47 +10:00
Asher Foa
f9bb147ee8 Add badge for docker pulls. 2019-07-01 08:43:24 +10:00
Michael Kaye
b12adc11e4 Update README.md
Allow non-superuser commands to be re-run without (some) errors.
2019-07-01 08:43:07 +10:00
SamB
0d4af2b71c No version metrics when default metrics disabled 2019-07-01 08:42:40 +10:00
Sean Corkum
07dd31dea6 Update README.md
add ; for any users that are copy/pasting from the readme
2019-06-15 19:39:39 +10:00
Asher Foa
c9dc7a20a1 remove unsupported postgres versions 2019-06-15 19:38:40 +10:00
Anthony Regeda
734dc50972 fix-panic-on-shutdown-server added test for const values parsing 2019-03-02 12:34:59 +10:00
Anthony Regeda
725b163161 fix-panic-on-shutdown-server fix panic on shutdown server 2019-03-02 12:34:59 +10:00