Repo Avatar
KingFRANKHOOD/Amana
Feature Description
Deploy a Grafana Loki + Promtail stack for centralized log aggregation across all services (backend, frontend, contracts event listener, PostgreSQL, Redis). Replace ad-hoc docker logs and kubectl logs with structured, searchable, and alertable logging.
Problem Statement
Currently, debugging production issues requires SSH-ing into pods/containers and running docker logs or kubectl logs. There is no centralized log search, no log-based alerting, and no way to correlate logs across services. Pino logs are structured JSON but sit on individual instances.
Proposed Solution
- Add Loki + Promtail to
docker-compose.yml staging profile:
loki:
image: grafana/loki:3.0
ports: ["3100:3100"]
promtail:
image: grafana/promtail:3.0
volumes: ["/var/log:/var/log", "/var/lib/docker/containers:/var/lib/docker/containers"]
- For K8s: deploy Loki via Helm chart (
grafana/loki-stack) with S3 storage backend
- Promtail config:
- Scrape Docker container logs (JSON file driver)
- Parse Pino-structured JSON: extract
level, service, trace_id, trade_id, error_code as labels
- Add
compose_service label for service discovery
- Grafana datasource: add Loki, create "Logs" explore view
- Log-based alerting (via Loki Ruler):
rate({service="backend"} | json | level="error" [5m]) > 10 → warning
rate({service="backend"} | json | error_code="DB_CONNECTION_FAILED" [5m]) > 0 → critical
rate({service="backend"} | json | level="fatal" [5m]) > 0 → critical
- Retention: 30 days (Loki), cold storage after 7 days
Alternatives Considered
- ELK stack (Elasticsearch, Logstash, Kibana) — heavier, more resource-intensive than Loki
- Datadog/Splunk — paid SaaS; not suitable for OSS self-hosted deployment
Impact Area
- Infrastructure
- Observability
Priority
P2 - Medium
Implementation Complexity
Moderate
Repo Avatar
KingFRANKHOOD/Amana
Feature Description
Deploy a Grafana Loki + Promtail stack for centralized log aggregation across all services (backend, frontend, contracts event listener, PostgreSQL, Redis). Replace ad-hoc
docker logsandkubectl logswith structured, searchable, and alertable logging.Problem Statement
Currently, debugging production issues requires SSH-ing into pods/containers and running
docker logsorkubectl logs. There is no centralized log search, no log-based alerting, and no way to correlate logs across services. Pino logs are structured JSON but sit on individual instances.Proposed Solution
docker-compose.ymlstaging profile:grafana/loki-stack) with S3 storage backendlevel,service,trace_id,trade_id,error_codeas labelscompose_servicelabel for service discoveryrate({service="backend"} | json | level="error" [5m]) > 10→ warningrate({service="backend"} | json | error_code="DB_CONNECTION_FAILED" [5m]) > 0→ criticalrate({service="backend"} | json | level="fatal" [5m]) > 0→ criticalAlternatives Considered
Impact Area
Priority
P2 - Medium
Implementation Complexity
Moderate