A minimal Flask-based monitoring dashboard for micro-services that ingests metrics, stores time-series data, and renders charts for operational visibility.
- Metrics Ingestion API: Token-gated endpoint for accepting metrics data
- Service Registry: Lightweight service tracking
- Time-Series Storage: SQL-based storage with 1-minute buckets
- Dashboard UI: Charts for latency, error rate, throughput, and uptime
- JSON Chart APIs: Fast, cacheable endpoints with query parameters
- Health Endpoints: Basic health and readiness checks
-
Install dependencies:
pip install -r requirements.txt
-
Set up environment:
cp .env.example .env # Edit .env as needed -
Initialize database:
flask --app wsgi.py db upgrade
-
Run development server:
flask --app wsgi.py --debug run
-
Access the dashboard:
- Overview: http://localhost:5000/dashboards/overview
- Health: http://localhost:5000/healthz
docker-compose up --buildGET /healthz- Basic health checkGET /readyz- Database connectivity check
POST /api/v1/ingest- Ingest metrics (requires X-API-Key header)
Example payload:
{
"service": "auth",
"environment": "prod",
"points": [
{
"metric": "latency_ms",
"ts": "2025-09-15T09:01:00Z",
"value": 112.3,
"labels": {"route": "/login"}
},
{
"metric": "error_rate",
"ts": "2025-09-15T09:01:00Z",
"value": 0.001
}
]
}GET /charts/latency?service=<name>&agg=p95&window=15mGET /charts/error_rate?service=<name>&window=1hGET /charts/throughput?service=<name>&window=1hGET /charts/uptime?service=<name>&window=24h
GET /api/v1/services- List all services
Ingest metrics:
curl -X POST http://localhost:5000/api/v1/ingest \
-H 'Content-Type: application/json' \
-H 'X-API-Key: local-dev-key' \
-d '{
"service":"auth","environment":"prod",
"points":[
{"metric":"latency_ms","ts":"2025-09-15T09:01:00Z","value":112.3,"labels":{"route":"/login"}},
{"metric":"error_rate","ts":"2025-09-15T09:01:00Z","value":0.001}
]}'Get chart data:
curl "http://localhost:5000/charts/latency?service=auth&agg=p95&window=15m"Environment variables (see .env.example):
SECRET_KEY: Flask secret keyDATABASE_URL: Database connection stringAPI_INGEST_KEYS: Comma-separated API keys for ingestionRETENTION_DAYS: Data retention period (default: 7)DEFAULT_WINDOW: Default chart window (default: 15m)DEFAULT_AGG: Default aggregation (default: p95)
pytest- Set
DATABASE_URLto PostgreSQL connection - Set secure
SECRET_KEYandAPI_INGEST_KEYS - Use gunicorn:
gunicorn wsgi:app - Set up reverse proxy (nginx/ALB)
- Configure monitoring and logging
- Flask: Web framework with blueprints
- SQLAlchemy: ORM for database operations
- Alembic: Database migrations
- HTMX: Dynamic UI updates
- Chart.js: Client-side charting
- Gunicorn: WSGI server for production