Fix activity query
* Modify the activity query to ensure each state is always reported. * Fix the activity preprocessor to unwrap the value from the array containing it.
This commit is contained in:
parent
175fd85f9f
commit
8182ad75b9
@ -196,12 +196,28 @@ metrics:
|
|||||||
type: set
|
type: set
|
||||||
query:
|
query:
|
||||||
0: >
|
0: >
|
||||||
SELECT state,
|
SELECT
|
||||||
count(*) AS backend_count,
|
states.state,
|
||||||
COALESCE(EXTRACT(EPOCH FROM max(now() - state_change)), 0) AS max_state_time
|
COALESCE(a.backend_count, 0) AS backend_count,
|
||||||
FROM pg_stat_activity
|
COALESCE(a.max_state_time, 0) AS max_state_time
|
||||||
WHERE datname = %(dbname)s
|
FROM (
|
||||||
GROUP BY state
|
SELECT state,
|
||||||
|
count(*) AS backend_count,
|
||||||
|
COALESCE(EXTRACT(EPOCH FROM now() - min(state_change)), 0) AS max_state_time
|
||||||
|
FROM pg_stat_activity
|
||||||
|
WHERE datname = %(dbname)s
|
||||||
|
GROUP BY state
|
||||||
|
) AS a
|
||||||
|
RIGHT JOIN
|
||||||
|
unnest(ARRAY[
|
||||||
|
'active',
|
||||||
|
'idle',
|
||||||
|
'idle in transaction',
|
||||||
|
'idle in transaction (aborted)',
|
||||||
|
'fastpath function call',
|
||||||
|
'disabled'
|
||||||
|
]) AS states(state)
|
||||||
|
USING (state);
|
||||||
test_args:
|
test_args:
|
||||||
dbname: postgres
|
dbname: postgres
|
||||||
|
|
||||||
@ -235,7 +251,7 @@ metrics:
|
|||||||
locks:
|
locks:
|
||||||
type: row
|
type: row
|
||||||
query:
|
query:
|
||||||
0:
|
0: >
|
||||||
SELECT COUNT(*) AS total,
|
SELECT COUNT(*) AS total,
|
||||||
SUM(CASE WHEN granted THEN 1 ELSE 0 END) AS granted
|
SUM(CASE WHEN granted THEN 1 ELSE 0 END) AS granted
|
||||||
FROM pg_locks
|
FROM pg_locks
|
||||||
|
|||||||
@ -411,7 +411,7 @@ zabbix_export:
|
|||||||
preprocessing:
|
preprocessing:
|
||||||
- type: JSONPATH
|
- type: JSONPATH
|
||||||
parameters:
|
parameters:
|
||||||
- '$[?(@.state == "active")].max_state_time'
|
- '$[?(@.state == "active")].max_state_time.first()'
|
||||||
master_item:
|
master_item:
|
||||||
key: 'pgmon_connection_states[{#DBNAME}]'
|
key: 'pgmon_connection_states[{#DBNAME}]'
|
||||||
tags:
|
tags:
|
||||||
@ -429,7 +429,7 @@ zabbix_export:
|
|||||||
preprocessing:
|
preprocessing:
|
||||||
- type: JSONPATH
|
- type: JSONPATH
|
||||||
parameters:
|
parameters:
|
||||||
- '$[?(@.state == "active")].backend_count'
|
- '$[?(@.state == "active")].backend_count.first()'
|
||||||
master_item:
|
master_item:
|
||||||
key: 'pgmon_connection_states[{#DBNAME}]'
|
key: 'pgmon_connection_states[{#DBNAME}]'
|
||||||
tags:
|
tags:
|
||||||
@ -448,7 +448,7 @@ zabbix_export:
|
|||||||
preprocessing:
|
preprocessing:
|
||||||
- type: JSONPATH
|
- type: JSONPATH
|
||||||
parameters:
|
parameters:
|
||||||
- '$[?(@.state == "disabled")].max_state_time'
|
- '$[?(@.state == "disabled")].max_state_time.first()'
|
||||||
master_item:
|
master_item:
|
||||||
key: 'pgmon_connection_states[{#DBNAME}]'
|
key: 'pgmon_connection_states[{#DBNAME}]'
|
||||||
tags:
|
tags:
|
||||||
@ -466,7 +466,7 @@ zabbix_export:
|
|||||||
preprocessing:
|
preprocessing:
|
||||||
- type: JSONPATH
|
- type: JSONPATH
|
||||||
parameters:
|
parameters:
|
||||||
- '$[?(@.state == "disabled")].backend_count'
|
- '$[?(@.state == "disabled")].backend_count.first()'
|
||||||
master_item:
|
master_item:
|
||||||
key: 'pgmon_connection_states[{#DBNAME}]'
|
key: 'pgmon_connection_states[{#DBNAME}]'
|
||||||
tags:
|
tags:
|
||||||
@ -485,7 +485,7 @@ zabbix_export:
|
|||||||
preprocessing:
|
preprocessing:
|
||||||
- type: JSONPATH
|
- type: JSONPATH
|
||||||
parameters:
|
parameters:
|
||||||
- '$[?(@.state == "fastpath function call")].max_state_time'
|
- '$[?(@.state == "fastpath function call")].max_state_time.first()'
|
||||||
master_item:
|
master_item:
|
||||||
key: 'pgmon_connection_states[{#DBNAME}]'
|
key: 'pgmon_connection_states[{#DBNAME}]'
|
||||||
tags:
|
tags:
|
||||||
@ -503,7 +503,7 @@ zabbix_export:
|
|||||||
preprocessing:
|
preprocessing:
|
||||||
- type: JSONPATH
|
- type: JSONPATH
|
||||||
parameters:
|
parameters:
|
||||||
- '$[?(@.state == "fastpath function call")].backend_count'
|
- '$[?(@.state == "fastpath function call")].backend_count.first()'
|
||||||
master_item:
|
master_item:
|
||||||
key: 'pgmon_connection_states[{#DBNAME}]'
|
key: 'pgmon_connection_states[{#DBNAME}]'
|
||||||
tags:
|
tags:
|
||||||
@ -522,7 +522,7 @@ zabbix_export:
|
|||||||
preprocessing:
|
preprocessing:
|
||||||
- type: JSONPATH
|
- type: JSONPATH
|
||||||
parameters:
|
parameters:
|
||||||
- '$[?(@.state == "idle")].max_state_time'
|
- '$[?(@.state == "idle")].max_state_time.first()'
|
||||||
master_item:
|
master_item:
|
||||||
key: 'pgmon_connection_states[{#DBNAME}]'
|
key: 'pgmon_connection_states[{#DBNAME}]'
|
||||||
tags:
|
tags:
|
||||||
@ -540,7 +540,7 @@ zabbix_export:
|
|||||||
preprocessing:
|
preprocessing:
|
||||||
- type: JSONPATH
|
- type: JSONPATH
|
||||||
parameters:
|
parameters:
|
||||||
- '$[?(@.state == "idle")].backend_count'
|
- '$[?(@.state == "idle")].backend_count.first()'
|
||||||
master_item:
|
master_item:
|
||||||
key: 'pgmon_connection_states[{#DBNAME}]'
|
key: 'pgmon_connection_states[{#DBNAME}]'
|
||||||
tags:
|
tags:
|
||||||
@ -559,7 +559,7 @@ zabbix_export:
|
|||||||
preprocessing:
|
preprocessing:
|
||||||
- type: JSONPATH
|
- type: JSONPATH
|
||||||
parameters:
|
parameters:
|
||||||
- '$[?(@.state == "idle in transaction (aborted)")].max_state_time'
|
- '$[?(@.state == "idle in transaction (aborted)")].max_state_time.first()'
|
||||||
master_item:
|
master_item:
|
||||||
key: 'pgmon_connection_states[{#DBNAME}]'
|
key: 'pgmon_connection_states[{#DBNAME}]'
|
||||||
tags:
|
tags:
|
||||||
@ -577,7 +577,7 @@ zabbix_export:
|
|||||||
preprocessing:
|
preprocessing:
|
||||||
- type: JSONPATH
|
- type: JSONPATH
|
||||||
parameters:
|
parameters:
|
||||||
- '$[?(@.state == "idle in transaction (aborted)")].backend_count'
|
- '$[?(@.state == "idle in transaction (aborted)")].backend_count.first()'
|
||||||
master_item:
|
master_item:
|
||||||
key: 'pgmon_connection_states[{#DBNAME}]'
|
key: 'pgmon_connection_states[{#DBNAME}]'
|
||||||
tags:
|
tags:
|
||||||
@ -596,7 +596,7 @@ zabbix_export:
|
|||||||
preprocessing:
|
preprocessing:
|
||||||
- type: JSONPATH
|
- type: JSONPATH
|
||||||
parameters:
|
parameters:
|
||||||
- '$[?(@.state == "idle in transaction")].max_state_time'
|
- '$[?(@.state == "idle in transaction")].max_state_time.first()'
|
||||||
master_item:
|
master_item:
|
||||||
key: 'pgmon_connection_states[{#DBNAME}]'
|
key: 'pgmon_connection_states[{#DBNAME}]'
|
||||||
tags:
|
tags:
|
||||||
@ -614,7 +614,7 @@ zabbix_export:
|
|||||||
preprocessing:
|
preprocessing:
|
||||||
- type: JSONPATH
|
- type: JSONPATH
|
||||||
parameters:
|
parameters:
|
||||||
- '$[?(@.state == "idle in transaction")].backend_count'
|
- '$[?(@.state == "idle in transaction")].backend_count.first()'
|
||||||
master_item:
|
master_item:
|
||||||
key: 'pgmon_connection_states[{#DBNAME}]'
|
key: 'pgmon_connection_states[{#DBNAME}]'
|
||||||
tags:
|
tags:
|
||||||
@ -633,7 +633,7 @@ zabbix_export:
|
|||||||
preprocessing:
|
preprocessing:
|
||||||
- type: JSONPATH
|
- type: JSONPATH
|
||||||
parameters:
|
parameters:
|
||||||
- '$[?(@.state == "starting")].max_state_time'
|
- '$[?(@.state == "starting")].max_state_time.first()'
|
||||||
master_item:
|
master_item:
|
||||||
key: 'pgmon_connection_states[{#DBNAME}]'
|
key: 'pgmon_connection_states[{#DBNAME}]'
|
||||||
tags:
|
tags:
|
||||||
@ -651,7 +651,7 @@ zabbix_export:
|
|||||||
preprocessing:
|
preprocessing:
|
||||||
- type: JSONPATH
|
- type: JSONPATH
|
||||||
parameters:
|
parameters:
|
||||||
- '$[?(@.state == "starting")].backend_count'
|
- '$[?(@.state == "starting")].backend_count.first()'
|
||||||
master_item:
|
master_item:
|
||||||
key: 'pgmon_connection_states[{#DBNAME}]'
|
key: 'pgmon_connection_states[{#DBNAME}]'
|
||||||
tags:
|
tags:
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user