-
Notifications
You must be signed in to change notification settings - Fork 773
add pg_stat_statements metrics #35
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
Could you rebase this? Also, do you think this would be a good candidate for being made an internal metric (how expensive is this query, basically)? |
Pay attention to this PR please, we also need this functionality in our monitoring system. |
queries.yaml
Outdated
description: "Owner of this database" | ||
- size: | ||
usage: "GAUGE" | ||
description: "Owner of this database" |
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.
I think this description is a copy & paste typo
queries.yaml
Outdated
metrics: | ||
- name: | ||
usage: "LABEL" | ||
description: "Name of the schema that this table is in" |
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.
And also doesn't really sound right. Should be "Name of the database"
FYI, requires pg_stat_statements so to be loaded via shared_preload_library statement. |
May be so: SELECT coalesce(d.datname, '~unknown') AS database, coalesce(r.rolname, '~unknown') AS user, s.query, s.calls, s.total_time, s.min_time, s.max_time, s.mean_time, s.stddev_time, s.rows, s.shared_blks_hit, s.shared_blks_read, s.shared_blks_dirtied, s.shared_blks_written, s.local_blks_hit, s.local_blks_read, s.local_blks_dirtied, s.local_blks_written, s.temp_blks_read, s.temp_blks_written, s.blk_read_time, s.blk_write_time FROM pg_stat_statements s JOIN pg_roles r ON r.oid=s.userid JOIN pg_database d ON d.oid=s.dbid WHERE d.datname NOT IN ('postgres', 'template0', 'template1') AND s.calls > 100 |
This pull request says "add pg_database_size metric", but what it actually does is use a view from the pg_stat_statements extension. I can't tell whether the votes for this pull were based on its description (database size) or its actual function (statement statistics) I would suggest closing this pull because it can't just be coded and merged this easily. Then a proper issue for pg_stats_statements should be opened to work out how to handle the tricky bit of version specific work. |
@gregscds Thanks for the analysis. It does raise the bigger issue of how that |
Got |
I've looped around at another job and now I want this again. |
What news with this request? 🐘 |
The |
Than you all for comments on this, this has lingered long enough. I've fixed the original issues and re-issued it as a new PR. |
I still think exposing the Otherwise, people risk getting "collected metric ... was collected before with the same name and label values" errors from Prometheus for the 'insufficient privileges' case as |
This incorporates pg_stat_statements in the example additional queries.