-
-
Notifications
You must be signed in to change notification settings - Fork 236
feat: INDATA-552 add pg_class-based table size metrics to postgres_exporter #2096
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
base: develop
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,34 @@ | ||
| pg_table_size: | ||
| query: | | ||
| SELECT | ||
| n.nspname AS schema, | ||
| c.relname AS table, | ||
| c.reltuples AS row_estimate, | ||
| pg_total_relation_size(c.oid) AS total_bytes, | ||
| pg_relation_size(c.oid) AS table_bytes, | ||
| pg_indexes_size(c.oid) AS index_bytes, | ||
| COALESCE(pg_total_relation_size(NULLIF(c.reltoastrelid, 0)), 0) AS toast_bytes | ||
| FROM pg_class c | ||
| JOIN pg_namespace n ON n.oid = c.relnamespace | ||
| WHERE c.relkind = 'r' | ||
| AND n.nspname NOT IN ('pg_catalog', 'information_schema') | ||
| metrics: | ||
| - schema: | ||
| usage: LABEL | ||
| - table: | ||
| usage: LABEL | ||
| - row_estimate: | ||
| usage: GAUGE | ||
| description: "Estimated row count from pg_class.reltuples" | ||
| - total_bytes: | ||
| usage: GAUGE | ||
| description: "Total size including indexes and toast" | ||
| - table_bytes: | ||
| usage: GAUGE | ||
| description: "Table data size" | ||
| - index_bytes: | ||
| usage: GAUGE | ||
| description: "Total index size" | ||
| - toast_bytes: | ||
| usage: GAUGE | ||
| description: "Toast size" | ||
| Original file line number | Diff line number | Diff line change | ||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -35,6 +35,15 @@ | |||||||||||||
| extra_opts: [--strip-components=1] | ||||||||||||||
| become: yes | ||||||||||||||
|
|
||||||||||||||
| - name: deploy queries.yml for custom metrics | ||||||||||||||
| copy: | ||||||||||||||
| src: files/queries.yml | ||||||||||||||
| dest: /opt/postgres_exporter/queries.yml | ||||||||||||||
| owner: root | ||||||||||||||
| group: root | ||||||||||||||
| mode: '0644' | ||||||||||||||
|
Comment on lines
+42
to
+44
|
||||||||||||||
| owner: root | |
| group: root | |
| mode: '0644' | |
| owner: postgres | |
| group: postgres | |
| mode: '0640' |
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.
The schema filter excludes only
pg_catalogandinformation_schema, which means this query will also export metrics for system schemas likepg_toast(and potentiallypg_temp_*). That adds noisy/high-cardinality series (including toast tables themselves) and can increase scrape cost. Consider explicitly excludingpg_toastand temporary schemas (or alternatively whitelisting the intended application schemas).