Skip to content

Commit 1e1f5cd

Browse files
author
tony-landreth
committed
Adds OTel metrics for Postgres
Issue: PGO-2036
1 parent 38fc33a commit 1e1f5cd

14 files changed

+1418
-4
lines changed

internal/collector/generated/gte_pg16_metrics.json

Lines changed: 1 addition & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

internal/collector/generated/lt_pg16_metrics.json

Lines changed: 1 addition & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

internal/collector/generated/pgbackrest_metrics.json

Lines changed: 1 addition & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

internal/collector/generated/postgres_5m_metrics.json

Lines changed: 1 addition & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

internal/collector/generated/postgres_5s_metrics.json

Lines changed: 1 addition & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Lines changed: 115 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,115 @@
1+
# This list of queries configures an OTel SQL Query Receiver to read pgMonitor
2+
# metrics from Postgres.
3+
#
4+
# https://github.com/open-telemetry/opentelemetry-collector-contrib/blob/-/receiver/sqlqueryreceiver#metrics-queries
5+
# https://github.com/CrunchyData/pgmonitor/blob/development/sql_exporter/common/crunchy_global_collector.yml
6+
7+
# TODO: This file is the same as lt_pg16_metris.yaml except for 1 line. Can we DRY this up?
8+
# NOTE: Some of the columns below can return NULL values, for which sqlqueryreceiver will warn.
9+
# Those columns are idx_scan and idx_tup_fetch.
10+
- sql: >
11+
SELECT
12+
current_database() as dbname
13+
, p.schemaname
14+
, p.relname
15+
, p.seq_scan
16+
, p.seq_tup_read
17+
, p.idx_scan
18+
, p.idx_tup_fetch
19+
, p.n_tup_ins
20+
, p.n_tup_upd
21+
, p.n_tup_del
22+
, p.n_tup_hot_upd
23+
, p.n_tup_newpage_upd
24+
, p.n_live_tup
25+
, p.n_dead_tup
26+
, p.vacuum_count
27+
, p.autovacuum_count
28+
, p.analyze_count
29+
, p.autoanalyze_count
30+
FROM pg_catalog.pg_stat_user_tables p;
31+
metrics:
32+
- metric_name: ccp_stat_user_tables_analyze_count
33+
value_column: analyze_count
34+
description: Number of times this table has been manually analyzed
35+
attribute_columns: ["dbname", "relname", "schemaname"]
36+
static_attributes:
37+
server: "localhost:5432"
38+
- metric_name: ccp_stat_user_tables_autoanalyze_count
39+
value_column: autoanalyze_count
40+
description: Number of times this table has been analyzed by the autovacuum daemon
41+
attribute_columns: ["dbname", "relname", "schemaname"]
42+
static_attributes:
43+
server: "localhost:5432"
44+
- metric_name: ccp_stat_user_tables_autovacuum_count
45+
value_column: autovacuum_count
46+
description: Number of times this table has been vacuumed by the autovacuum daemon
47+
attribute_columns: ["dbname", "relname", "schemaname"]
48+
static_attributes:
49+
server: "localhost:5432"
50+
- metric_name: ccp_stat_user_tables_idx_scan
51+
value_column: idx_scan
52+
description: Number of index scans initiated on this table
53+
attribute_columns: ["dbname", "relname", "schemaname"]
54+
static_attributes:
55+
server: "localhost:5432"
56+
- metric_name: ccp_stat_user_tables_idx_tup_fetch
57+
value_column: idx_tup_fetch
58+
description: Number of live rows fetched by index scans
59+
attribute_columns: ["dbname", "relname", "schemaname"]
60+
static_attributes:
61+
server: "localhost:5432"
62+
- metric_name: ccp_stat_user_tables_n_dead_tup
63+
value_column: n_dead_tup
64+
description: Estimated number of dead rows
65+
attribute_columns: ["dbname", "relname", "schemaname"]
66+
static_attributes:
67+
server: "localhost:5432"
68+
- metric_name: ccp_stat_user_tables_n_live_tup
69+
value_column: n_live_tup
70+
description: Estimated number of live rows
71+
attribute_columns: ["dbname", "relname", "schemaname"]
72+
static_attributes:
73+
server: "localhost:5432"
74+
- metric_name: ccp_stat_user_tables_n_tup_del
75+
value_column: n_tup_del
76+
description: Number of rows deleted
77+
attribute_columns: ["dbname", "relname", "schemaname"]
78+
static_attributes:
79+
server: "localhost:5432"
80+
- metric_name: ccp_stat_user_tables_n_tup_hot_upd
81+
value_column: n_tup_hot_upd
82+
description: Number of rows HOT updated (i.e., with no separate index update required)
83+
attribute_columns: ["dbname", "relname", "schemaname"]
84+
static_attributes:
85+
server: "localhost:5432"
86+
- metric_name: ccp_stat_user_tables_n_tup_ins
87+
value_column: n_tup_ins
88+
description: Number of rows inserted
89+
attribute_columns: ["dbname", "relname", "schemaname"]
90+
static_attributes:
91+
server: "localhost:5432"
92+
- metric_name: ccp_stat_user_tables_n_tup_upd
93+
value_column: n_tup_upd
94+
description: Number of rows updated
95+
attribute_columns: ["dbname", "relname", "schemaname"]
96+
static_attributes:
97+
server: "localhost:5432"
98+
- metric_name: ccp_stat_user_tables_seq_scan
99+
value_column: seq_scan
100+
description: Number of sequential scans initiated on this table
101+
attribute_columns: ["dbname", "relname", "schemaname"]
102+
static_attributes:
103+
server: "localhost:5432"
104+
- metric_name: ccp_stat_user_tables_seq_tup_read
105+
value_column: seq_tup_read
106+
description: Number of live rows fetched by sequential scans
107+
attribute_columns: ["dbname", "relname", "schemaname"]
108+
static_attributes:
109+
server: "localhost:5432"
110+
- metric_name: ccp_stat_user_tables_vacuum_count
111+
value_column: vacuum_count
112+
description: Number of times this table has been manually vacuumed (not counting VACUUM FULL)
113+
attribute_columns: ["dbname", "relname", "schemaname"]
114+
static_attributes:
115+
server: "localhost:5432"

0 commit comments

Comments
 (0)