-
Notifications
You must be signed in to change notification settings - Fork 796
Add all integer/real runtime variables #61
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
I'm interested in feedback on this PR - this change adds a lot of metrics (at least 339 on my test setup), which I'm not sure is desired. I'd also like to look at adding some tests for this PR before it's considered for merging. |
c7695f6
to
8de4d50
Compare
Rebased to fix the integration test. |
Test wise we'd want to figure out how to assert the unit inference works version to version I think, which might be a bit of a change to how I run the tests now since the best way would be to do a like to like comparison across postgres versions where one unit matches. Adding 300+ metrics which don't change much should be okay for Prometheus since unchanging metrics yield a pointer update in the backend and no additional storage use. At the very least Prometheus should be arbitrating what it wants to accept, not us. |
postgres_exporter.go
Outdated
switch unit { | ||
case "": | ||
case "min": | ||
suffix = "minimum" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
not minute
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good catch.
@wrouesnel: Prometheus can compress these kinds of metrics efficiently, however the overhead of indexing and retaining the extra timeseries in-memory is worth considering IMHO. I think it's probably fine - these are useful metrics to have and we could always put them behind a feature flag in future if users complained. |
8de4d50
to
5a5347c
Compare
I miscounted the number of metrics - I've included |
Sorry for the delay on this, picking it up again. |
2cf60d6
to
6fb45dc
Compare
Updated to add tests, please take a look. |
cc9a506
to
51aefbb
Compare
Hopefully I'll have time in the next few days. Thanks for the great work on this! |
Use the `pg_settings` view to retrieve runtime variables: https://www.postgresql.org/docs/current/static/view-pg-settings.html This replaces the use of `SHOW` to retrieve runtime variables. In PostgreSQL 9.6, this adds 189 metrics, which use the `short_desc` field as a description. Only runtime variables with a `vartype` of `bool`, `real`, or `integer` are currently supported. Example metrics: # HELP pg_settings_allow_system_table_mods Allows modifications of the structure of system tables. # TYPE pg_settings_allow_system_table_mods gauge pg_settings_allow_system_table_mods 0 # HELP pg_settings_archive_timeout_seconds Forces a switch to the next xlog file if a new file has not been started within N seconds. [Units converted to seconds.] # TYPE pg_settings_archive_timeout_seconds gauge pg_settings_archive_timeout_seconds 0 # HELP pg_settings_array_nulls Enable input of NULL elements in arrays. # TYPE pg_settings_array_nulls gauge pg_settings_array_nulls 1 # HELP pg_settings_authentication_timeout_seconds Sets the maximum allowed time to complete client authentication. [Units converted to seconds.] # TYPE pg_settings_authentication_timeout_seconds gauge pg_settings_authentication_timeout_seconds 60 # HELP pg_settings_autovacuum Starts the autovacuum subprocess. # TYPE pg_settings_autovacuum gauge pg_settings_autovacuum 1 # HELP pg_settings_autovacuum_analyze_scale_factor Number of tuple inserts, updates, or deletes prior to analyze as a fraction of reltuples. # TYPE pg_settings_autovacuum_analyze_scale_factor gauge pg_settings_autovacuum_analyze_scale_factor 0.1 # HELP pg_settings_autovacuum_analyze_threshold Minimum number of tuple inserts, updates, or deletes prior to analyze. # TYPE pg_settings_autovacuum_analyze_threshold gauge pg_settings_autovacuum_analyze_threshold 50 # HELP pg_settings_autovacuum_freeze_max_age Age at which to autovacuum a table to prevent transaction ID wraparound. # TYPE pg_settings_autovacuum_freeze_max_age gauge pg_settings_autovacuum_freeze_max_age 2e+08 # HELP pg_settings_autovacuum_max_workers Sets the maximum number of simultaneously running autovacuum worker processes. # TYPE pg_settings_autovacuum_max_workers gauge pg_settings_autovacuum_max_workers 3 # HELP pg_settings_autovacuum_multixact_freeze_max_age Multixact age at which to autovacuum a table to prevent multixact wraparound. # TYPE pg_settings_autovacuum_multixact_freeze_max_age gauge pg_settings_autovacuum_multixact_freeze_max_age 4e+08 # HELP pg_settings_autovacuum_naptime_seconds Time to sleep between autovacuum runs. [Units converted to seconds.] # TYPE pg_settings_autovacuum_naptime_seconds gauge pg_settings_autovacuum_naptime_seconds 60 # HELP pg_settings_autovacuum_vacuum_cost_delay_seconds Vacuum cost delay in milliseconds, for autovacuum. [Units converted to seconds.] # TYPE pg_settings_autovacuum_vacuum_cost_delay_seconds gauge pg_settings_autovacuum_vacuum_cost_delay_seconds 0.02 # HELP pg_settings_autovacuum_vacuum_cost_limit Vacuum cost amount available before napping, for autovacuum. # TYPE pg_settings_autovacuum_vacuum_cost_limit gauge pg_settings_autovacuum_vacuum_cost_limit -1 # HELP pg_settings_autovacuum_vacuum_scale_factor Number of tuple updates or deletes prior to vacuum as a fraction of reltuples. # TYPE pg_settings_autovacuum_vacuum_scale_factor gauge pg_settings_autovacuum_vacuum_scale_factor 0.2 # HELP pg_settings_autovacuum_vacuum_threshold Minimum number of tuple updates or deletes prior to vacuum. # TYPE pg_settings_autovacuum_vacuum_threshold gauge pg_settings_autovacuum_vacuum_threshold 50 # HELP pg_settings_autovacuum_work_mem_bytes Sets the maximum memory to be used by each autovacuum worker process. [Units converted to bytes.] # TYPE pg_settings_autovacuum_work_mem_bytes gauge pg_settings_autovacuum_work_mem_bytes -1
4fba1b4
to
f9df40d
Compare
Spent some time augmenting the integration tests so I could inspect the result of this. In future I definitely need to have CI send comments automatically for me - across all versions: Removed Metrics
Added Metrics
Two metrics not retained (looking at the short names) between the versions are:
Which looks to be because we pick up "seconds" instead. So nothing's lost and I'll add this data to release notes. |
Closed by 98ba566 I ended up doing some rebasing and touch-ups on the commit messages, but your authorship is preserved. Great work - I'll think on it for another few days and cut a new release then. |
Thanks! |
Fixes #60.
Use the
pg_settings
view to retrieve runtime variables:https://www.postgresql.org/docs/current/static/view-pg-settings.html
This replaces the use of
SHOW
to retrieve runtime variables.In PostgreSQL 9.6, this adds 339 metrics, which use the
short_desc
field as a description.
Only runtime variables with a
vartype
ofreal
orinteger
arecurrently supported.
Example metrics:
Tries to use the
unit
column from thepg_settings
view to determinewhich unit a metric is using, and normalise the metrics accordingly to
match Prometheus conventions:
https://prometheus.io/docs/practices/naming/
Settings with units of
8kB
are not normalised because most of thosemetrics are counting pages rather than bytes, e.g.: