Skip to content

Commit

Permalink
Pg16 Support (#367)
Browse files Browse the repository at this point in the history
* feat: add support for PG16

* chore: update changelog and docs
  • Loading branch information
keithf4 authored Sep 19, 2023
1 parent df6aa96 commit 3d81103
Show file tree
Hide file tree
Showing 8 changed files with 731 additions and 1 deletion.
2 changes: 2 additions & 0 deletions changelogs/fragments/366.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
major_changes:
- postgres_exporter - Add support for PostgreSQL 16
1 change: 0 additions & 1 deletion hugo/content/_index.md
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,6 @@ pgMonitor combines multiple open-source software packages and necessary configur
- RHEL 7/8 (Build/Run Testing, Setup Instructions)
- CentOS 7 (Build/Run Testing, Setup Instructions)
- Ubuntu 20 (Build/Run Testing)
- SLES 15.4 (Build/Run Testing)

### PostgreSQL

Expand Down
31 changes: 31 additions & 0 deletions postgres_exporter/common/pg16/queries_general.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
###
#
# Begin File: PG16 queries_general.yml
#
# Copyright © 2017-2023 Crunchy Data Solutions, Inc. All Rights Reserved.
#
###


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: PG16 queries_general.yml
#
###
169 changes: 169 additions & 0 deletions postgres_exporter/common/pg16/queries_pg_stat_statements.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,169 @@
###
#
# Begin File: PG16 queries_pg_stat_statements.yml
#
# Copyright © 2017-2023 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: PG16 queries_pg_stat_statements.yml
#
###
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
###
#
# Begin File: pg_stat_statements_reset_info.yml
#
# Copyright © 2017-2023 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

0 comments on commit 3d81103

Please sign in to comment.