Monitoring Configuration
SLOzy exposes Prometheus-compatible metrics and ships with pre-configured alert rules and Grafana provisioning.
Prometheus Targets
The main prometheus/prometheus.yml defines the following scrape jobs:
| Job | Target | Scrape Interval | Purpose |
|---|---|---|---|
slozy-web | slozy-web-service:80 | 30s | Application metrics (/metrics) |
kubernetes-pods | Auto-discovery via pod annotations | 15s | All annotated pods |
kubernetes-api-server | Kubernetes API | 15s | Cluster health |
postgres-exporter | postgres-exporter:9187 | 15s | Database metrics |
redis-exporter | redis-exporter:9121 | 15s | Redis metrics |
For non-Kubernetes deployments, use the simplified deploy/prometheus.yml which targets localhost:8080:
scrape_configs:
- job_name: 'slozy'
static_configs:
- targets: ['localhost:8080']
metrics_path: /metrics
scrape_interval: 15sMetrics Endpoint
The application exposes a /metrics endpoint (enabled via METRICS_ENABLED=true, default port 9090). Key metric categories:
http_requests_total— request count by method, path, status codehttp_request_duration_seconds— histogram of response timesslo_status— current burn-rate status per SLOcache_hits/cache_misses— cache efficiencywebsocket_connections_total— real-time connection countprocess_resident_memory_bytes— memory usage
Alert Rules
Alerting rules are defined in prometheus/alerts/alerts.yml (Kubernetes) and deploy/slozy-alerts.yml (standalone). Pre-configured alerts:
| Alert Name | Severity | Condition |
|---|---|---|
ApplicationDown | critical | up{job="slozy-web"} == 0 for 2m |
HighErrorRate | warning | 5xx rate > 5% over 5m |
HighLatency | warning | P95 latency > 1s over 5m |
VeryHighLatency | critical | P99 latency > 5s over 2m |
HighMemoryUsage | warning | Container memory > 80% for 5m |
DatabaseDown | critical | Postgres pod unreachable for 2m |
HighDatabaseConnections | warning | Active connections > 80 |
CriticalSLOViolation | critical | Any SLO in critical status for 5m |
MultipleSLOViolations | warning | 3+ SLOs in warning/critical for 10m |
Alertmanager is configured to deliver notifications via Slack, email, or PagerDuty. Set alertmanager:9093 as the target in your Prometheus config.
Grafana Dashboards
The docker-compose.yml includes a Grafana container (port 3001) with provisioning from grafana/provisioning/ and dashboard definitions from grafana/dashboards/.
Conceptual dashboards to create:
- SLO Overview — burn-rate status for all SLOs, error budget remaining, time to exhaustion
- Application Performance — request rate, latency (P50/P95/P99), error rate by endpoint
- Database — connection pool usage, query duration, cache hit ratio
- Infrastructure — CPU/memory per pod, disk usage, network I/O
Default Grafana credentials: admin / admin. Change these in production.
Running the Stack
# Full stack with monitoring
docker-compose up -d
# Or bring up monitoring standalone
docker-compose up -d prometheus grafana
# Access Grafana
open http://localhost:3001Retention
| Component | Setting | Default |
|---|---|---|
| Prometheus TSDB | retention.time | 30d |
| Prometheus TSDB | retention.size | 10GB |
| Grafana | Snapshots / DB | Configurable via GF_* env vars |
Adjust retention in prometheus/prometheus.yml under the storage.tsdb section.