This repository contains configurations and scripts to implement a full-stack observability layer for CI/CD pipelines, as described in the CI/CD observability handbook. The setup includes Grafana Loki, a lightweight ELK stack, Vector, and OpenTelemetry for log aggregation, metrics, and tracing.
- loki/: Configuration files for Grafana Loki and Promtail to aggregate and scrape logs.
loki-config.yamlincludes core setup, retention policies (7-day log retention), and storage settings.promtail-config.yamlincludes setups for both general system logs (/var/log/*.log) and GitHub Actions logs (/var/log/gha/*.log). - elk/: Docker Compose and configuration files for a lightweight ELK stack (Elasticsearch, Logstash, Kibana) and Vector.
- scripts/: Shell scripts for log collection, analysis, notifications, and self-healing pipelines.
- examples/: Example CI/CD pipeline configurations (GitHub Actions, GitLab CI, Jenkins) and code snippets for logging and tracing. The
github-actions-workflow.ymlincludes both log forwarding to Loki and correlation ID for tracing.
- Navigate to
loki/. - Run
docker-compose up -dto start Loki and Promtail. - Update
loki-config.yamlfor storage paths or retention periods if needed (e.g.,/tmp/loki/chunksfor log storage, 7-day retention). - Update
promtail-config.yamlto point to your CI/CD log directories (e.g.,/var/log/*.logfor system logs,/var/log/gha/*.logfor GitHub Actions).
- Navigate to
elk/. - Run
docker-compose up -dto start Elasticsearch, Logstash, and Kibana. - Configure Filebeat (
filebeat.yml) or Vector (vector.toml) to forward logs to Logstash or Elasticsearch.
- Use scripts in
scripts/for automated log collection (collect_logs.sh), error analysis (log-analysis.sh), notifications (slack-notification.sh), and self-healing (self-healing.sh).
- Use example configurations in
examples/for GitHub Actions, GitLab CI, or Jenkins to forward logs to Loki or ELK. Thegithub-actions-workflow.ymldemonstrates running tests with log forwarding to Loki and logging with a correlation ID for traceability. - Implement structured logging with correlation IDs using
winston-logger.jsor tracing withopentelemetry-python.py.
- Configure log rotation with
logrotate.confand Docker logging withdaemon.json. - Set retention policies in
loki-config.yaml(Loki, 7-day retention) orelasticsearch-ilm.json(ELK).
- Docker and Docker Compose for running Loki and ELK.
- Node.js for running JavaScript examples (
winston-logger.js,prometheus-exemplar.js). - Python for OpenTelemetry example (
opentelemetry-python.py). - At least 4GB RAM and 20GB disk space for Loki; 8GB RAM and 30GB disk for ELK.
- Replace placeholders like
http://your-loki-endpointorYOUR_SLACK_WEBHOOK_URLwith your actual endpoints. - Ensure logs are written to the paths specified in configuration files (e.g., `/var/log/ci/*.