Repository navigation
feat: log aggregation — Loki/Elasticsearch shipping with documented label schema - #10
Merged
Merged
Conversation
…ed label schema - Add Loki + Promtail services to docker-compose.observability.yml so `make obs-up` starts the full observability stack (Prometheus, Grafana, Loki, Promtail) in one command - observability/loki-config.yml: single-node filesystem storage (v13 schema) - observability/promtail-config.yml: Docker SD, compose-project filter, JSON pipeline stage; promotes level + logger to stream labels; maps request_id / workspace_id / user_id to structured metadata - observability/grafana/provisioning/datasources/loki.yml: Loki datasource auto-provisioned alongside Prometheus - backend/app/observability.py: optional _LokiHandler and _ElasticsearchHandler — batched background-thread push for environments without a sidecar agent; activated by LOKI_URL / ELASTICSEARCH_URL env vars - backend/app/config.py: loki_url, elasticsearch_url, log_service_name settings - backend/app/main.py: wire configure_log_shippers() on startup - backend/app/worker/celery_app.py: wire configure_log_shippers() via worker_process_init signal so the Celery worker ships logs independently - docs/log-aggregation.md: label schema reference, LogQL query examples, env var table, Promtail project filter instructions
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
make obs-upnow starts Prometheus, Grafana, Loki, and Promtail together. Promtail scrapes Docker container stdout/stderr using Docker service discovery, filtered to theautoflowopscompose project, and ships streams to Loki. The pipeline extractslevelandloggeras stream labels;request_id,workspace_id, anduser_idas structured metadata.LOKI_URLorELASTICSEARCH_URLto activate background-thread handlers (_LokiHandler,_ElasticsearchHandler) that batch and push log entries directly from the backend and Celery worker processes — no sidecar required.docs/log-aggregation.mdwith stream labels, structured metadata fields, example LogQL queries, and env var reference.Files changed
docker-compose.observability.ymlloki_datavolumeobservability/loki-config.ymlobservability/promtail-config.ymlobservability/grafana/provisioning/datasources/loki.ymlbackend/app/observability.py_LokiHandler,_ElasticsearchHandler,configure_log_shippers()backend/app/config.pyloki_url,elasticsearch_url,log_service_namebackend/app/main.pyconfigure_log_shippers()on startupbackend/app/worker/celery_app.pyworker_process_initsignaldocs/log-aggregation.mdTest plan
make obs-upstarts cleanly; Grafana at http://localhost:3001 shows both Prometheus and Loki datasources{app="autoflowops"}LOKI_URL=http://loki:3100, backend logs are shipped directly (check Loki API:curl http://localhost:3100/loki/api/v1/labels)LOKI_URLandELASTICSEARCH_URLboth unset, no handlers are added (default behaviour unchanged)