Yaml parsing refactor (#299)
* Use struct instead of interface{} when parsing query user
* Use MappingOptions
* Split function to be more testable
* Rename function to parseUserQueries
* Start to add test about query parsing
This commit is contained in:
committed by
Will Rouesnel
parent
e1428a8330
commit
ececfdeab7
23
cmd/postgres_exporter/tests/user_queries_ok.yaml
Normal file
23
cmd/postgres_exporter/tests/user_queries_ok.yaml
Normal file
@@ -0,0 +1,23 @@
|
||||
pg_locks_mode:
|
||||
query: "WITH q_locks AS (select * from pg_locks where pid != pg_backend_pid() and database = (select oid from pg_database where datname = current_database())) SELECT (select current_database()) as datname,
|
||||
lockmodes AS tag_lockmode, coalesce((select count(*) FROM q_locks WHERE mode = lockmodes), 0) AS count FROM
|
||||
unnest('{AccessShareLock, ExclusiveLock, RowShareLock, RowExclusiveLock, ShareLock, ShareRowExclusiveLock, AccessExclusiveLock, ShareUpdateExclusiveLock}'::text[]) lockmodes;"
|
||||
metrics:
|
||||
- datname:
|
||||
usage: "LABEL"
|
||||
description: "Database name"
|
||||
- tag_lockmode:
|
||||
usage: "LABEL"
|
||||
description: "Lock type"
|
||||
- count:
|
||||
usage: "GAUGE"
|
||||
description: "Number of lock"
|
||||
pg_wal:
|
||||
query: "select current_database() as datname, case when pg_is_in_recovery() = false then pg_xlog_location_diff(pg_current_xlog_location(), '0/0')::int8 else pg_xlog_location_diff(pg_last_xlog_replay_location(), '0/0')::int8 end as xlog_location_b;"
|
||||
metrics:
|
||||
- datname:
|
||||
usage: "LABEL"
|
||||
description: "Database name"
|
||||
- xlog_location_b:
|
||||
usage: "COUNTER"
|
||||
description: "current transaction log write location"
|
||||
Reference in New Issue
Block a user