feat(obs): add Loki ruler alert rules and MONITORING.md Loki section (BIT-19957)
- deploy/loki/rules/fake/errors_hub_alerts.yaml: four LogQL-based Loki ruler alert rules (error rate per service, fatal detection, ingest-api sustained errors, collector-worker stall detection) - deploy/loki/loki.yaml: add explicit ruler.storage (local), rule_path, and enable_api/enable_alertmanager_v2 so Loki loads rules from /loki/rules - docker-compose.yml: mount deploy/loki/rules → /loki/rules:ro in the loki service (observability profile) - docs/MONITORING.md: add Loki section with label table, alert rule summary, config file index, and LXC deployment note Paperclip-Issue: BIT-19957 Paperclip-Agent: cto
This commit is contained in:
1 parent
c74e05b844
commit
113eee0b97
4 files changed
+142
No files matched your search
@@ -24,3 +24,58 @@ Company standards for signals (logs, metrics, tracing, alerting) are summarized
|
||||
| Grafana dashboard JSON (import into your Grafana) | [`../deploy/grafana/error-monitoring-dashboard.json`](../deploy/grafana/error-monitoring-dashboard.json) |
|
||||
|
||||
Scrape **both** the hub API and the ingest API; see `OBSERVABILITY_PROMETHEUS.md` for paths and metric families.
|
||||
|
||||
---
|
||||
|
||||
## Log aggregation (Loki)
|
||||
|
||||
| Topic | Location |
|
||||
|-------|----------|
|
||||
| Architecture, labels, LogQL queries, troubleshooting | [`OBSERVABILITY_LOKI.md`](OBSERVABILITY_LOKI.md) |
|
||||
| Loki server config (schema, retention, ruler) | [`../deploy/loki/loki.yaml`](../deploy/loki/loki.yaml) |
|
||||
| Promtail config — Docker Compose lab | [`../deploy/loki/promtail.yaml`](../deploy/loki/promtail.yaml) |
|
||||
| Promtail config — LXC / production | [`../deploy/loki/promtail-lxc.yaml`](../deploy/loki/promtail-lxc.yaml) |
|
||||
| Promtail systemd unit (LXC) | [`../deploy/loki/systemd/promtail.service`](../deploy/loki/systemd/promtail.service) |
|
||||
| Grafana log dashboard | [`../deploy/grafana/loki-logs-dashboard.json`](../deploy/grafana/loki-logs-dashboard.json) |
|
||||
| Loki ruler alert rules | [`../deploy/loki/rules/fake/errors_hub_alerts.yaml`](../deploy/loki/rules/fake/errors_hub_alerts.yaml) |
|
||||
| LXC operational runbook | [`deployment/loki-lxc-runbook.md`](deployment/loki-lxc-runbook.md) |
|
||||
|
||||
### Labels
|
||||
|
||||
Every log line from errors-hub carries these Loki labels:
|
||||
|
||||
| Label | Values |
|
||||
|-------|--------|
|
||||
| `app` | `errors-hub` (static) |
|
||||
| `env` | `production` (static) |
|
||||
| `service` | `ingest-api`, `api`, `collector-worker`, `admin-ui`, `web` |
|
||||
| `level` | `info`, `warn`, `error`, `fatal` (normalised from Pino numeric levels) |
|
||||
|
||||
Labels are consistent across Docker Compose (Docker SD) and LXC (journald) deployments.
|
||||
`trace` and `debug` lines are dropped by Promtail in both configs.
|
||||
|
||||
### Starting the observability stack
|
||||
|
||||
```bash
|
||||
# Docker Compose (lab) — core services + Loki + Promtail
|
||||
docker compose --profile observability up -d
|
||||
|
||||
# Verify log ingestion
|
||||
curl -s 'http://localhost:3100/loki/api/v1/labels'
|
||||
```
|
||||
|
||||
### Alert rules (Loki ruler)
|
||||
|
||||
Rules live in `deploy/loki/rules/fake/errors_hub_alerts.yaml` and are evaluated by the Loki ruler component.
|
||||
|
||||
| Alert | Condition | Severity |
|
||||
|-------|-----------|----------|
|
||||
| `ErrorsHubServiceErrorRateHigh` | Any service >0.1 error lines/s for 5m | warning |
|
||||
| `ErrorsHubFatalLogDetected` | Any fatal line in any service for 1m | critical |
|
||||
| `ErrorsHubIngestApiHighErrorRate` | ingest-api >0.05 error lines/s for 10m | critical |
|
||||
| `ErrorsHubCollectorWorkerStalled` | collector-worker silent for 15m | warning |
|
||||
|
||||
Alerts route to Alertmanager (`ruler.alertmanager_url` in `deploy/loki/loki.yaml`).
|
||||
For production LXC: point `alertmanager_url` to the central Alertmanager (`http://<observability-ct>:9093`).
|
||||
|
||||
For production LXC deployment, copy `deploy/loki/rules/` to `/loki/rules/` on the Loki LXC; see [`deployment/loki-lxc-runbook.md`](deployment/loki-lxc-runbook.md).
|
||||
Reference in new issue
Block a user