Lightweight metric anomaly detection dashboard with Prometheus streaming
Project description
MetriSight
A lightweight, self-hosted metric anomaly dashboard for developers. Detects anomalies in time-series metrics using statistical methods — no ML expertise or expensive APM tools required.
Features
- Prometheus live streaming — connect to any Prometheus instance, auto-refresh on a configurable interval
- Real-time anomaly detection using Z-score and Moving Average methods
- Interactive dashboard with Plotly charts and Streamlit
- CSV upload — bring your own metric data from any source
- Simulated metrics (CPU, Memory, Latency) with injected anomalies for demo
- Configurable thresholds via sidebar controls
Quick Start
pip install -r requirements.txt
streamlit run app.py
The dashboard opens at http://localhost:8501. By default it runs with simulated metrics — switch to Prometheus (Live) or Upload CSV in the sidebar.
Connecting to Prometheus (Live Streaming)
MetriSight connects directly to your Prometheus instance and streams metrics with configurable auto-refresh.
Setup
- Select Prometheus (Live) in the sidebar
- Enter your Prometheus URL (e.g.,
http://localhost:9090) - Enter a PromQL query (e.g.,
rate(node_cpu_seconds_total{mode="idle"}[5m])) - Choose a lookback window (1h, 6h, 24h, or 7 days)
- Set auto-refresh interval (15s, 30s, 1m, or 5m) for live monitoring
- Click Test Connection to verify connectivity
Example PromQL queries
# CPU usage rate
rate(node_cpu_seconds_total{mode="idle"}[5m])
# Memory usage percentage
(1 - node_memory_MemAvailable_bytes / node_memory_MemTotal_bytes) * 100
# HTTP request latency (p95)
histogram_quantile(0.95, rate(http_request_duration_seconds_bucket[5m]))
# HTTP error rate
rate(http_requests_total{status=~"5.."}[5m])
# Disk I/O utilization
rate(node_disk_io_time_seconds_total[5m])
Authentication
MetriSight supports authenticated Prometheus instances. Select the auth method in the sidebar under the Prometheus section.
| Method | When to use | Setup |
|---|---|---|
| None | Local/internal Prometheus without auth | Default, no config needed |
| Bearer Token | Grafana Cloud, Thanos, Cortex, managed Prometheus | Paste your API token |
| Basic Auth | Prometheus behind nginx/Apache reverse proxy | Enter username + password |
Credentials are passed via HTTP headers only — they are never logged, stored on disk, or displayed in the UI (password fields are masked).
Grafana Cloud example:
- Get your API token from Grafana Cloud > your stack > Prometheus > Details
- Set Prometheus URL to your Grafana Cloud Prometheus endpoint (e.g.,
https://prometheus-prod-01-eu-west-0.grafana.net/api/prom) - Select Bearer Token and paste your API key
- Click Test Connection to verify — you'll see the Prometheus version if auth succeeds, or a
401 Unauthorizederror if the token is wrong
How it works
- MetriSight queries the Prometheus
/api/v1/query_rangeendpoint - The lookback window determines how far back to fetch (rolling window)
- Auto-refresh re-queries Prometheus on the set interval, so the chart updates with live data
- Anomaly detection runs on each refresh against the full lookback window
Lookback window guide
| Window | Best for | Typical resolution |
|---|---|---|
| 1 hour | Real-time incident triage | 15s |
| 6 hours | Shift monitoring | 30s - 1m |
| 24 hours | Daily pattern analysis | 1m |
| 7 days | Weekly trend detection | 5m |
Other Data Sources
CSV Upload
Upload a CSV file with two columns:
timestamp,value
2024-01-15 10:00:00,45.2
2024-01-15 10:01:00,47.8
2024-01-15 10:02:00,44.1
Exporting from other tools
CloudWatch:
aws cloudwatch get-metric-statistics \
--namespace AWS/EC2 --metric-name CPUUtilization \
--start-time 2024-01-15T00:00:00Z --end-time 2024-01-15T23:59:59Z \
--period 60 --statistics Average --output json \
| python3 -c "
import json, sys, csv
data = json.load(sys.stdin)['Datapoints']
data.sort(key=lambda x: x['Timestamp'])
w = csv.writer(sys.stdout)
w.writerow(['timestamp', 'value'])
for d in data:
w.writerow([d['Timestamp'], d['Average']])
" > cloudwatch_cpu.csv
Datadog:
curl -s "https://api.datadoghq.com/api/v1/query?from=$(date -d '24 hours ago' +%s)&to=$(date +%s)&query=avg:system.cpu.user{*}" \
-H "DD-API-KEY: $DD_API_KEY" -H "DD-APPLICATION-KEY: $DD_APP_KEY" \
| python3 -c "
import json, sys, csv
from datetime import datetime
data = json.load(sys.stdin)['series'][0]['pointlist']
w = csv.writer(sys.stdout)
w.writerow(['timestamp', 'value'])
for ts_ms, val in data:
w.writerow([datetime.fromtimestamp(ts_ms / 1000).isoformat(), val])
" > datadog_cpu.csv
Programmatic Usage
import pandas as pd
from metrisight.detector import detect_zscore, get_anomaly_summary
df = pd.read_csv("my_metrics.csv")
df["timestamp"] = pd.to_datetime(df["timestamp"])
result = detect_zscore(df, threshold=3.0)
summary = get_anomaly_summary(result)
print(f"Found {summary['anomaly_count']} anomalies ({summary['anomaly_pct']}%)")
How It Works
MetriSight uses two statistical methods to detect anomalies:
- Z-Score Detection — flags data points that deviate more than N standard deviations from the mean
- Moving Average Detection — flags data points that deviate from a rolling mean by more than N rolling standard deviations
Project Structure
metrisight/
├── app.py # Streamlit dashboard
├── metrisight/
│ ├── simulator.py # Generates realistic fake metrics
│ ├── detector.py # Anomaly detection algorithms
│ ├── prometheus.py # Prometheus HTTP API client
│ └── charts.py # Plotly chart builders
└── tests/
├── test_detector.py # Detection algorithm tests
└── test_prometheus.py # Prometheus client tests
License
MIT
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file metrisight-0.1.1.tar.gz.
File metadata
- Download URL: metrisight-0.1.1.tar.gz
- Upload date:
- Size: 15.1 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
7b5d0641059fd483b57433d514bd86f687794ffc44c337432112ff0572d8ecd5
|
|
| MD5 |
d8c0c3349c7bf37143c4045d87e16243
|
|
| BLAKE2b-256 |
8a4c776f5d1d3c31dd832bf9d7818a2ab92a50aad59a1741afea3bb50ae2bdf9
|
Provenance
The following attestation bundles were made for metrisight-0.1.1.tar.gz:
Publisher:
publish.yml on pallaprolus/metrisight
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
metrisight-0.1.1.tar.gz -
Subject digest:
7b5d0641059fd483b57433d514bd86f687794ffc44c337432112ff0572d8ecd5 - Sigstore transparency entry: 954386498
- Sigstore integration time:
-
Permalink:
pallaprolus/metrisight@82eb339e6ee5eff1f801be099c78d152ec61da02 -
Branch / Tag:
refs/tags/v0.1.1 - Owner: https://github.com/pallaprolus
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@82eb339e6ee5eff1f801be099c78d152ec61da02 -
Trigger Event:
release
-
Statement type:
File details
Details for the file metrisight-0.1.1-py3-none-any.whl.
File metadata
- Download URL: metrisight-0.1.1-py3-none-any.whl
- Upload date:
- Size: 11.8 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
e0b95a38e07fba2fab2583e31323645d153cb3eaadb3dcb54dfded07dfc6ad58
|
|
| MD5 |
c59881f91ced85727add3166d20a7bb4
|
|
| BLAKE2b-256 |
657d54a7079a66505459267d7ae90114a3b409b340a3090af3bb798cdeb1508a
|
Provenance
The following attestation bundles were made for metrisight-0.1.1-py3-none-any.whl:
Publisher:
publish.yml on pallaprolus/metrisight
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
metrisight-0.1.1-py3-none-any.whl -
Subject digest:
e0b95a38e07fba2fab2583e31323645d153cb3eaadb3dcb54dfded07dfc6ad58 - Sigstore transparency entry: 954386499
- Sigstore integration time:
-
Permalink:
pallaprolus/metrisight@82eb339e6ee5eff1f801be099c78d152ec61da02 -
Branch / Tag:
refs/tags/v0.1.1 - Owner: https://github.com/pallaprolus
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@82eb339e6ee5eff1f801be099c78d152ec61da02 -
Trigger Event:
release
-
Statement type: