Fix empty Caddy and pg_stat_statements panels in service-health dashboard
- Caddy Response Status Codes: caddy_http_responses_total doesn't exist, use caddy_http_response_duration_seconds_count which has the code label - pg_stat_statements: enable extension in init script, add custom queries config for postgres-exporter, remove invalid datname filter from query - Add postgres/queries.yml to cd-infra SCP sources Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
parent
b7e3d315ab
commit
3adf6fbfc4
5 changed files with 37 additions and 3 deletions
|
|
@ -1,3 +1,6 @@
|
|||
-- Enable pg_stat_statements for query performance monitoring
|
||||
CREATE EXTENSION IF NOT EXISTS pg_stat_statements;
|
||||
|
||||
-- Read-only user for Grafana dashboards
|
||||
-- Password is set via: ALTER ROLE grafana_reader PASSWORD '<from SOPS>'
|
||||
-- Run by cd-infra deploy script after container start
|
||||
|
|
|
|||
28
infrastructure/postgres/queries.yml
Normal file
28
infrastructure/postgres/queries.yml
Normal file
|
|
@ -0,0 +1,28 @@
|
|||
pg_stat_statements:
|
||||
query: |
|
||||
SELECT
|
||||
queryid,
|
||||
LEFT(query, 80) AS query,
|
||||
calls,
|
||||
mean_exec_time / 1000.0 AS mean_time_seconds,
|
||||
total_exec_time / 1000.0 AS total_time_seconds
|
||||
FROM pg_stat_statements
|
||||
WHERE dbid = (SELECT oid FROM pg_database WHERE datname = 'trails')
|
||||
ORDER BY mean_exec_time DESC
|
||||
LIMIT 20
|
||||
metrics:
|
||||
- queryid:
|
||||
usage: "LABEL"
|
||||
description: "Query ID"
|
||||
- query:
|
||||
usage: "LABEL"
|
||||
description: "Query text (truncated)"
|
||||
- calls:
|
||||
usage: "GAUGE"
|
||||
description: "Number of calls"
|
||||
- mean_time_seconds:
|
||||
usage: "GAUGE"
|
||||
description: "Mean execution time in seconds"
|
||||
- total_time_seconds:
|
||||
usage: "GAUGE"
|
||||
description: "Total execution time in seconds"
|
||||
Loading…
Add table
Add a link
Reference in a new issue