Skip to content

Ahmed Baha Eddine Alimi - B23-SD-01 [Lab07 + Bonus Task]#8

Merged
3llimi merged 1 commit intomasterfrom
lab07
Mar 7, 2026
Merged

Ahmed Baha Eddine Alimi - B23-SD-01 [Lab07 + Bonus Task]#8
3llimi merged 1 commit intomasterfrom
lab07

Conversation

@3llimi
Copy link
Copy Markdown
Owner

@3llimi 3llimi commented Mar 5, 2026

Lab 07 — Observability & Logging with Loki Stack

What was done:

  • Deployed centralized logging stack (Loki 3.0 + Promtail 3.0 + Grafana 12.3.1) via Docker Compose with shared logging network
  • Configured Loki with TSDB storage backend (schema v13), 7-day retention, and compactor for automatic log cleanup
  • Configured Promtail with Docker service discovery via socket — only scrapes containers with logging=promtail label, extracts app and container labels via relabeling
  • Updated Python app to output structured JSON logs using a custom JSONFormatter — each request logs method, path, status_code, client_ip, duration_seconds as top-level JSON fields
  • Integrated both apps (devops-python, devops-go) into the logging stack with Docker labels for Promtail filtering
  • Built Grafana dashboard "DevOps Apps - Log Overview" with 4 panels: Logs Table, Request Rate (time series), Error Logs, and Log Level Distribution (pie chart)
  • Configured production hardening: resource limits on all services, health checks for Loki and Grafana, Grafana anonymous access disabled, secrets in .env excluded from git
  • Verified idempotency — second run produces changed=0

Bonus:

  • Created roles/monitoring Ansible role with block/rescue/always structure, Jinja2-templated configs, and role dependency on docker via meta/main.yml
  • All versions, ports, retention period, and resource limits parameterised in defaults/main.yml — fully configurable without touching role code
  • Confirmed idempotency with community.docker.docker_compose_v2changed=0 on second run

@3llimi 3llimi merged commit c91b27e into master Mar 7, 2026
5 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant