Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adds pg17 files to postgres_exporter #435

Open
wants to merge 1 commit into
base: development
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
44 changes: 44 additions & 0 deletions postgres_exporter/common/pg17/queries_general.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
###
#
# Begin File: PG17 queries_general.yml
#
# Copyright © 2017-2024 Crunchy Data Solutions, Inc. All Rights Reserved.
#
###

ccp_stat_bgwriter:
query: "SELECT buffers_clean, maxwritten_clean, buffers_alloc FROM pg_catalog.pg_stat_bgwriter"
metrics:
- buffers_clean:
usage: "GAUGE"
description: "Number of buffers written by the background writer"
- maxwritten_clean:
usage: "GAUGE"
description: "Number of times the background writer stopped a cleaning scan because it had written too many buffers"
- buffers_alloc:
usage: "GAUGE"
description: "Number of buffers allocated"


ccp_data_checksum_failure:
query: "SELECT datname AS dbname
, checksum_failures AS count
, coalesce(extract(epoch from (clock_timestamp() - checksum_last_failure)), 0) AS time_since_last_failure_seconds
FROM pg_catalog.pg_stat_database;"
metrics:
- dbname:
usage: "LABEL"
description: "Database name"
- count:
usage: "GAUGE"
description: "Total number of checksum failures on this database"
- time_since_last_failure_seconds:
usage: "GAUGE"
description: "Time interval in seconds since the last checksum failure was encountered"


###
#
# End File: PG17 queries_general.yml
#
###
169 changes: 169 additions & 0 deletions postgres_exporter/common/pg17/queries_pg_stat_statements.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,169 @@
###
#
# Begin File: PG17 queries_pg_stat_statements.yml
#
# Copyright © 2017-2024 Crunchy Data Solutions, Inc. All Rights Reserved.
#
###

ccp_pg_stat_statements_total:
query: "SELECT pg_get_userbyid(s.userid) as role,
d.datname AS dbname,
sum(s.calls) AS calls_count,
sum(s.total_exec_time) AS exec_time_ms,
avg(s.mean_exec_time) AS mean_exec_time_ms,
sum(s.rows) AS row_count
FROM public.pg_stat_statements s
JOIN pg_catalog.pg_database d
ON d.oid = s.dbid
GROUP BY 1,2"
metrics:
- role:
usage: "LABEL"
description: "Role that executed the statement"
- dbname:
usage: "LABEL"
description: "Database in which the statement was executed"
- calls_count:
usage: "GAUGE"
description: "Total number of queries run per user/database"
- exec_time_ms:
usage: "GAUGE"
description: "Total runtime of all queries per user/database"
- mean_exec_time_ms:
usage: "GAUGE"
description: "Mean runtime of all queries per user/database"
- row_count:
usage: "GAUGE"
description: "Total rows returned from all queries per user/database"


ccp_pg_stat_statements_top_mean:
query: "SELECT pg_get_userbyid(s.userid) as role,
d.datname AS dbname,
s.queryid,
btrim(replace(left(s.query, 40), '\n', '')) AS query,
max(s.mean_exec_time) exec_time_ms
FROM public.pg_stat_statements s
JOIN pg_catalog.pg_database d
ON d.oid = s.dbid
GROUP BY 1,2,3,4
ORDER BY 5 DESC
LIMIT #PG_STAT_STATEMENTS_LIMIT#"
metrics:
- role:
usage: "LABEL"
description: "Role that executed the statement"
- dbname:
usage: "LABEL"
description: "Database in which the statement was executed"
- queryid:
usage: "LABEL"
description: "Internal hash code, computed from the statement's parse tree"
- query:
usage: "LABEL"
description: "First 40 characters of query text"
- exec_time_ms:
usage: "GAUGE"
description: "Average query runtime in milliseconds"


ccp_pg_stat_statements_top_total:
query: "SELECT pg_get_userbyid(s.userid) as role,
d.datname AS dbname,
s.queryid,
btrim(replace(left(s.query, 40), '\n', '')) AS query,
s.total_exec_time exec_time_ms
FROM public.pg_stat_statements s
JOIN pg_catalog.pg_database d
ON d.oid = s.dbid
ORDER BY 5 DESC
LIMIT #PG_STAT_STATEMENTS_LIMIT#"
metrics:
- role:
usage: "LABEL"
description: "Role that executed the statement"
- dbname:
usage: "LABEL"
description: "Database in which the statement was executed"
- queryid:
usage: "LABEL"
description: "Internal hash code, computed from the statement's parse tree"
- query:
usage: "LABEL"
description: "First 40 characters of query text"
- exec_time_ms:
usage: "GAUGE"
description: "Total time spent in the statement in milliseconds"


ccp_pg_stat_statements_top_max:
query: "SELECT pg_get_userbyid(s.userid) as role,
d.datname AS dbname,
s.queryid,
btrim(replace(left(s.query, 40), '\n', '')) AS query,
s.max_exec_time AS exec_time_ms
FROM public.pg_stat_statements s
JOIN pg_catalog.pg_database d
ON d.oid = s.dbid
ORDER BY 5 DESC
LIMIT #PG_STAT_STATEMENTS_LIMIT#"
metrics:
- role:
usage: "LABEL"
description: "Role that executed the statement"
- dbname:
usage: "LABEL"
description: "Database in which the statement was executed"
- queryid:
usage: "LABEL"
description: "Internal hash code, computed from the statement's parse tree"
- query:
usage: "LABEL"
description: "First 40 characters of query text"
- exec_time_ms:
usage: "GAUGE"
description: "Maximum time spent in the statement in milliseconds"


ccp_pg_stat_statements_top_wal:
query: "SELECT pg_get_userbyid(s.userid) as role,
d.datname AS dbname,
s.queryid,
btrim(replace(left(s.query, 40), '\n', '')) AS query,
s.wal_records AS records,
s.wal_fpi AS fpi,
s.wal_bytes AS bytes
FROM public.pg_stat_statements s
JOIN pg_catalog.pg_database d
ON d.oid = s.dbid
ORDER BY s.wal_bytes DESC
LIMIT #PG_STAT_STATEMENTS_LIMIT#"
metrics:
- role:
usage: "LABEL"
description: "Role that executed the statement"
- dbname:
usage: "LABEL"
description: "Database in which the statement was executed"
- queryid:
usage: "LABEL"
description: "Internal hash code, computed from the statement's parse tree"
- query:
usage: "LABEL"
description: "First 40 characters of query text"
- records:
usage: "GAUGE"
description: "Total number of WAL records generated by the statement"
- fpi:
usage: "GAUGE"
description: "Total number of WAL full page images generated by the statement"
- bytes:
usage: "GAUGE"
description: "Total amount of WAL generated by the statement in bytes"

###
#
# End File: PG17 queries_pg_stat_statements.yml
#
###
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
###
#
# Begin File: pg_stat_statements_reset_info.yml
#
# Copyright © 2017-2024 Crunchy Data Solutions, Inc. All Rights Reserved.
#
###
ccp_pg_stat_statements_reset:
query: "select monitor.pg_stat_statements_reset_info(#PG_STAT_STATEMENTS_THROTTLE_MINUTES#) as time"
metrics:
- time:
usage: "GAUGE"
description: "Epoch time when stats were reset"

###
#
# End File: pg_stat_statements_reset_info.yml
#
###
Loading
Loading