-
Notifications
You must be signed in to change notification settings - Fork 93
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add pg_stat_statements metrics & dashboard (#200)
- Loading branch information
Showing
23 changed files
with
1,140 additions
and
511 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
83 changes: 0 additions & 83 deletions
83
exporter/postgres/crunchy-postgres-exporter-pg94-el6.service
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,134 @@ | ||
### | ||
# | ||
# Begin File: queries_pg_stat_statements.yml | ||
# | ||
### | ||
|
||
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_time) AS time_ms, | ||
avg(s.mean_time) AS mean_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" | ||
- time_ms: | ||
usage: "GAUGE" | ||
description: "Total runtime of all queries per user/database" | ||
- mean_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_time) 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" | ||
- time_ms: | ||
usage: "GAUGE" | ||
description: "Average query runtime in milliseconds" | ||
|
||
|
||
# Note that individual query stats can only be reset in PG12 | ||
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_time 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" | ||
- time_ms: | ||
usage: "GAUGE" | ||
description: "Total time spent in the statement in milliseconds" | ||
|
||
|
||
# Note that individual query stats can only be reset in PG12 | ||
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_time AS 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" | ||
- time_ms: | ||
usage: "GAUGE" | ||
description: "Maximum time spent in the statement in milliseconds" | ||
|
||
|
||
### | ||
# | ||
# End File: queries_pg_stat_statements.yml | ||
# | ||
### | ||
|
Oops, something went wrong.