Skip to content

talosaether/dshbrd

Repository files navigation

Monitoring Dashboard

A minimal Flask-based monitoring dashboard for micro-services that ingests metrics, stores time-series data, and renders charts for operational visibility.

Features

  • 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

Quick Start

Development Setup

  1. Install dependencies:

    pip install -r requirements.txt
  2. Set up environment:

    cp .env.example .env
    # Edit .env as needed
  3. Initialize database:

    flask --app wsgi.py db upgrade
  4. Run development server:

    flask --app wsgi.py --debug run
  5. Access the dashboard:

Docker Development

docker-compose up --build

API Endpoints

Health

  • GET /healthz - Basic health check
  • GET /readyz - Database connectivity check

Metrics Ingestion

  • 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
    }
  ]
}

Chart Data

  • GET /charts/latency?service=<name>&agg=p95&window=15m
  • GET /charts/error_rate?service=<name>&window=1h
  • GET /charts/throughput?service=<name>&window=1h
  • GET /charts/uptime?service=<name>&window=24h

Services

  • GET /api/v1/services - List all services

Sample cURL Commands

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"

Configuration

Environment variables (see .env.example):

  • SECRET_KEY: Flask secret key
  • DATABASE_URL: Database connection string
  • API_INGEST_KEYS: Comma-separated API keys for ingestion
  • RETENTION_DAYS: Data retention period (default: 7)
  • DEFAULT_WINDOW: Default chart window (default: 15m)
  • DEFAULT_AGG: Default aggregation (default: p95)

Testing

pytest

Production Deployment

  1. Set DATABASE_URL to PostgreSQL connection
  2. Set secure SECRET_KEY and API_INGEST_KEYS
  3. Use gunicorn: gunicorn wsgi:app
  4. Set up reverse proxy (nginx/ALB)
  5. Configure monitoring and logging

Architecture

  • 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

About

monitoring dashboard

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors