A hands-on development lab covering application metrics, centralized logs, Slack alert notifications, and controlled recovery verification.
Installing observability tools is easy; proving that metrics, logs, and alert notifications actually flow end-to-end is the real engineering work. For my November 2026 technical closeout (commit e7d6871), I instrumented and verified a complete observability pipeline for a Dockerized Flask application running in a local Kubernetes development environment.
This post documents the architecture, the exact queries verified, the controlled recovery check, and the engineering limitations recorded in the repository.
1. Architecture Overview
The observability setup was scoped intentionally to the dev namespace across three distinct telemetry paths:
Metrics: Flask → ServiceMonitor → Prometheus → Grafana
Flask Application (/metrics) │ ▼ Kubernetes Service │ ▼ ServiceMonitor (release=kps) │ ▼ Prometheus ──(PromQL)──► Grafana Dashboard Logs: Flask → Grafana Alloy → Loki → LogQL
Flask Container Logs │ ▼ Grafana Alloy (namespace-scoped: dev) │ ▼ Loki Monolithic ──(LogQL)──► Log Exploration Alerting: Prometheus → Alertmanager → Slack
Prometheus Alerting ──► Alertmanager ──► Slack (FIRING / RESOLVED) 2. Prometheus — Scraping Custom Flask Metrics
The running Flask application exposed a /metrics endpoint. After inspecting the source inside the dev container, /metrics was excluded from request instrumentation to prevent self-scrape noise from skewing application counters.
The ServiceMonitor (flask-dev, labeled release=kps) was configured to scrape /metrics on port 5000 for services matching app=flask-app in the dev namespace. Prometheus confirmed the target status as UP with zero scrape errors.
PromQL Verification
To confirm application-specific telemetry was queryable, I ran:
sum(rate(flask_http_request_total[5m])) During verification, this returned a point-in-time sample rate of 0.3 requests/second, with underlying counter samples capturing both HTTP 200 and HTTP 500 responses. (Note: This is an observed snapshot during testing, not a load-test benchmark.)
3. Grafana — Building and Exporting a Dashboard
I built a dashboard named Flask Dev Observability containing six panels:
- Flask request rate
- HTTP requests by status
- Request rate by route
- P95 latency by route
- Container CPU usage
- Container memory usage
The dashboard was exported and committed as validated JSON (flask-dev-observability-dashboard.json) so the artifact is version-controlled alongside the manifests rather than relying solely on screenshots.
4. Grafana Alloy & Loki — Scoped Log Aggregation
Rather than ingesting logs cluster-wide, I configured Grafana Alloy to discover and collect logs strictly from the dev namespace filtered by app=flask-app. Stream labels (namespace, pod, app, container) and static labels (environment=dev, job=flask-dev) were attached before pushing to a single-replica Loki Monolithic instance running local filesystem storage with a 24-hour retention window.
LogQL Verification
Querying recent application streams in Loki:
{environment="dev",job="flask-dev"} This returned recent Flask HTTP entries (/health, /, and /metrics) with HTTP 200 responses. A secondary query ({namespace="dev",app="flask-app"}) confirmed stream isolation.
5. Alertmanager — Controlled Slack Notification Test
To validate the alerting delivery path, I triggered a controlled synthetic alert rule routed through Alertmanager to a test Slack channel with sendResolved enabled. Both FIRING and RESOLVED notifications arrived cleanly, confirming end-to-end state-transition delivery.
(Note: This synthetic test verified the notification pipeline itself; it does not claim production alert rule tuning or incident detection.)
6. Controlled Dev Service Recovery & AWS Read-Only Inventory
- Service Endpoint Recovery: Separately from the Slack test, I performed a dev-only Service recovery drill by intentionally mismatching the Flask Service selector, confirming its endpoints emptied, restoring
app=flask-app, and verifying endpoint recovery. Production workloads were untouched. - AWS Read-Only Audit: I ran a read-only inventory of candidate idle AWS resources (stopped practice EC2 instances, attached EBS volumes, and an unassociated Elastic IP) for later review. No AWS resources were modified, and no cost savings were claimed since Cost Explorer access was restricted.
7. Honest Engineering Limitations
A reliable closeout documents what is not production-ready:
- Development Scope Only: This is a local Kubernetes lab, not a production observability platform.
- Ephemeral Loki Storage: Loki uses single-replica local
emptyDirstorage; logs are not durable across pod restarts. - Disk-Budget Exception: The node had
4.4 GiBfree disk space at verification—below the preferred8 GiBheadroom threshold—and was explicitly logged as a capacity exception. - Image Tagging: While the running container's SHA256 digest was recorded, the Deployment manifest references an image tag rather than a pinned digest.
- Historical Restarts: Earlier pod restarts with exit code
255(reasonUnknown) were noted without assigning an unverified root cause.
8. Evidence & Repository
All acceptance records and dashboard exports are committed in the repository:
- GitHub Repository: tanayjdev/k8s-flask-devops-capstone
- November Closeout Index:
monitoring/evidence/november-closeout.md - Stage 1 & Stage 2 Records:
stage1-acceptance.md|stage2-acceptance.md

