From 98b74d9aed5bdfc1341fb7f32989808e0f7262e6 Mon Sep 17 00:00:00 2001 From: James Campbell Date: Fri, 4 Jul 2025 02:45:43 -0400 Subject: [PATCH] Add sequence metrics to Zabbix template --- sample-config/pgmon-metrics.yml | 2 +- zabbix_templates/pgmon_templates.yaml | 81 +++++++++++++++++++++++++++ 2 files changed, 82 insertions(+), 1 deletion(-) diff --git a/sample-config/pgmon-metrics.yml b/sample-config/pgmon-metrics.yml index 67251db..cb537d2 100644 --- a/sample-config/pgmon-metrics.yml +++ b/sample-config/pgmon-metrics.yml @@ -226,7 +226,7 @@ metrics: type: row query: 100000: > - SELECT COUNT(*) FILTER (WHERE has_sequence_privilege(c.oid, 'SELECT,USAGE')) AS readable_sequences, + SELECT COUNT(*) FILTER (WHERE has_sequence_privilege(c.oid, 'SELECT,USAGE')) AS visible_sequences, COUNT(*) AS total_sequences FROM pg_class AS c WHERE relkind = 'S'; diff --git a/zabbix_templates/pgmon_templates.yaml b/zabbix_templates/pgmon_templates.yaml index 997e1fa..f982e33 100644 --- a/zabbix_templates/pgmon_templates.yaml +++ b/zabbix_templates/pgmon_templates.yaml @@ -785,6 +785,76 @@ zabbix_export: value: PostgreSQL - tag: Database value: '{#DBNAME}' + - uuid: 5960120dd01c4926b0fc1fbe9c011507 + name: 'Database max sequence usage in {#DBNAME}' + type: HTTP_AGENT + key: 'pgmon_db_max_sequence[{#DBNAME}]' + delay: 5m + value_type: FLOAT + units: '%' + description: 'The percent of the currently configured value range for the most utilized sequence.' + url: 'http://localhost:{$AGENT_PORT}/sequence_usage' + query_fields: + - name: dbname + value: '{#DBNAME}' + tags: + - tag: Application + value: PostgreSQL + - tag: Database + value: '{#DBNAME}' + - uuid: 48b9cc80ac4d4aee9e9f3a5d6f7d4a95 + name: 'Total number of sequences on {#DBNAME}' + type: DEPENDENT + key: 'pgmon_db_sequences[total,{#DBNAME}]' + delay: '0' + description: 'Total number of sequences in the database.' + preprocessing: + - type: JSONPATH + parameters: + - $.total_sequences + master_item: + key: 'pgmon_db_sequence_visibility[{#DBNAME}]' + tags: + - tag: Application + value: PostgreSQL + - tag: Database + value: '{#DBNAME}' + - uuid: 6521a9bab2ac47bf85429832d289bbac + name: 'Visible sequences on {#DBNAME}' + type: DEPENDENT + key: 'pgmon_db_sequences[visible,{#DBNAME}]' + delay: '0' + description: 'Number of sequences in the database for which Zabbix can see stats.' + preprocessing: + - type: JSONPATH + parameters: + - $.visible_sequences + master_item: + key: 'pgmon_db_sequence_visibility[{#DBNAME}]' + tags: + - tag: Application + value: PostgreSQL + - tag: Database + value: '{#DBNAME}' + - uuid: 00f2da3eb99940839410a6ecd5df153f + name: 'Database sequence visibility in {#DBNAME}' + type: HTTP_AGENT + key: 'pgmon_db_sequence_visibility[{#DBNAME}]' + delay: 30m + value_type: TEXT + trends: '0' + description: 'Statistics about the number of sequences that exist and the number Zabbix can actually see stats for.' + url: 'http://localhost:{$AGENT_PORT}/sequence_visibility' + query_fields: + - name: dbname + value: '{#DBNAME}' + tags: + - tag: Application + value: PostgreSQL + - tag: Database + value: '{#DBNAME}' + - tag: Type + value: Raw - uuid: 492b3cac15f348c2b85f97b69c114d1b name: 'Database Stats for {#DBNAME}' type: HTTP_AGENT @@ -803,6 +873,17 @@ zabbix_export: value: '{#DBNAME}' - tag: Type value: Raw + trigger_prototypes: + - uuid: d29d0fd9d9d34b5ebd649592b0829ce5 + expression: 'last(/PostgreSQL by pgmon/pgmon_db_sequences[total,{#DBNAME}]) <> last(/PostgreSQL by pgmon/pgmon_db_sequences[visible,{#DBNAME}])' + name: 'Sequences not visible to Zabbix on {#DBNAME}' + priority: WARNING + description: 'There are sequences for which Zabbix cannot see usage statistics' + tags: + - tag: Application + value: PostgreSQL + - tag: Component + value: Sequence graph_prototypes: - uuid: 1f7de43b77714f819e61c31273712b70 name: 'DML Totals for {#DBNAME}'