Observability - local Grafana session#155
Conversation
…shboard Enables pg_stat_statements on the postgres container and provisions a Grafana dashboard with panels for slowest queries by mean time, highest total-time queries, most-called queries, and p50/p95/p99 latency stats. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Adds postgres_exporter + Prometheus to the compose stack so Grafana reads query stats from Prometheus time-series rather than hitting the primary DB on every dashboard refresh. Moves CREATE EXTENSION into a Flyway migration (V14) instead of a manual step. Updates the Grafana dashboard to use PromQL. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
| postgres_exporter: | ||
| image: prometheuscommunity/postgres-exporter:latest | ||
| command: | ||
| - '--extend.query-path=/etc/postgres_exporter/queries.yaml' |
There was a problem hiding this comment.
The --extend.query-path option seems to be deprecated (see: https://github.com/prometheus-community/postgres_exporter). Please remove it for now.
| - postgres | ||
| volumes: | ||
| - grafana_data:/var/lib/grafana | ||
| - ./config/grafana/provisioning:/etc/grafana/provisioning:ro |
There was a problem hiding this comment.
While I think having our data sources configured in-code is a good idea, I think it's out of scope for this current issue and we should try to implement it in a separate pull request
| volumes: | ||
| - grafana_data:/var/lib/grafana | ||
| - ./config/grafana/provisioning:/etc/grafana/provisioning:ro | ||
| - ./config/grafana/dashboards:/var/lib/grafana/dashboards:ro |
There was a problem hiding this comment.
Same thing with dashboards, while defining dashboards in-code might be viable in the future, we should try to change one thing at a time.
| restart: unless-stopped | ||
| environment: | ||
| GF_SERVER_ROOT_URL: "${GF_SERVER_ROOT_URL}" | ||
| DB_NAME: "${DB_NAME}" |
There was a problem hiding this comment.
Remove database credentials from Grafana until we're ready to config the datasource in-code (future issue)
| - '--storage.tsdb.retention.time=30d' | ||
| volumes: | ||
| - ./config/prometheus/prometheus.yml:/etc/prometheus/prometheus.yml:ro | ||
| - prometheus_data:/prometheus |
There was a problem hiding this comment.
Please name the in-container folder something more descriptive, e.g. prometheus_data
There was a problem hiding this comment.
This file is not mounted anywhere and I believe its contents are handled by the flyway migration file you wrote. So it can be safely deleted.
No description provided.