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"
