CLI tool to monitor API endpoint latency and detect degradation
Project description
ALM — API Latency Monitor
A small CLI tool for keeping an eye on HTTP endpoints. It polls them on an interval, stores the results in a local SQLite database, and prints a summary table whenever you want one. Nothing fancy and no servers, no dashboards, no accounts.
Motivation
I got tired of finding out an API was slow from a user complaint. Our internal dashboards tracked uptime but latency was a blind spot. Things would be technically "up" while responding in 2-3 seconds instead of 200ms, and nobody would notice until customers started complaining. I wanted something I could point at any endpoint, leave running in a terminal, and get a warning before it became an incident. This is that tool.
Install
git clone https://github.com/sukhleenk/API-Latency-Monitor
cd alm
pip install -e .
For dev (includes pytest):
pip install -e ".[dev]"
Setup
Copy the example config and edit it, or use alm add to build it interactively:
cp config.example.yaml config.yaml
endpoints:
- name: "Weather SLC"
url: "https://api.open-meteo.com/v1/forecast?latitude=40.7608&longitude=-111.8910¤t_weather=true"
method: GET
threshold_ms: 500
- name: "Auth Service"
url: "https://auth.example.com/ping"
method: GET
headers:
Authorization: "Bearer your-token"
threshold_ms: 200
threshold_ms is the latency limit you care about — anything over it gets counted as a breach. Defaults to 500ms if you leave it out.
Usage
Start monitoring:
alm monitor # polls every 60 seconds
alm monitor --interval 30 # poll every 30 seconds
alm monitor --config ./prod.yaml # use a different config
The terminal output is color-coded: [OK] is green, [WARN] is yellow (response time spiked more than 1.5x the rolling average), [FAIL] is red. Press Ctrl+C to stop.
View a report:
alm report
alm report --endpoint "Weather SLC" # one endpoint only
alm report --failures-only # only endpoints with breaches
alm report --since 24 # last 24 hours
alm report --export out.csv # export to CSV
Example output:
API Latency Report
╭─────────────────┬────────┬──────────┬─────────┬───────┬───────┬──────────┬──────────╮
│ Endpoint │ Checks │ Success% │ Avg(ms) │ Min │ Max │ Breaches │ Status │
├─────────────────┼────────┼──────────┼─────────┼───────┼───────┼──────────┼──────────┤
│ Weather NYC │ 42 │ 100.0% │ 187.3 │ 134.1 │ 312.5 │ 0 │ HEALTHY │
│ Weather SLC │ 42 │ 97.6% │ 431.8 │ 201.4 │ 891.2 │ 7 │ DEGRADED │
╰─────────────────┴────────┴──────────┴─────────┴───────┴───────┴──────────┴──────────╯
Status is HEALTHY (green) if success rate ≥ 80% and no threshold breaches, DEGRADED (yellow) if there have been breaches, and DOWN (red) if success rate drops below 80%.
Add an endpoint interactively:
alm add
Clear history:
alm clear
How it works
- Retries failed requests up to 3 times with exponential backoff (1s, 2s) before marking a check as failed
- Degradation detection compares the latest reading against the rolling average of the last 10 successful checks — if it's more than 50% above average, it prints a warning
- All data lives in
alm_data.db(SQLite) in the current directory
Tests
pytest tests/ -v
No network access needed. Storage tests use an in-memory SQLite db and monitor tests mock requests.
Contributing
I believe every piece of work on earth is better with collaboration, even more so for technological advancements and code. Feel free to suggest new features, or create pull requests to contribute to the project!
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 api_latency_monitor-0.1.0.tar.gz.
File metadata
- Download URL: api_latency_monitor-0.1.0.tar.gz
- Upload date:
- Size: 15.4 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.13.1
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
bc2ce2639834314fcae386dd88682c085e504f7c040ccfff716dc841951140a5
|
|
| MD5 |
349041b09ddbe2f36ec001e1d8921dd0
|
|
| BLAKE2b-256 |
284e80620c4455acafc8ddcecbf90f0d67489ccb24ad1ed6a9daf12d497e4b9e
|
File details
Details for the file api_latency_monitor-0.1.0-py3-none-any.whl.
File metadata
- Download URL: api_latency_monitor-0.1.0-py3-none-any.whl
- Upload date:
- Size: 15.9 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.13.1
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
0127a53a93b1246b6193b6edb7be9dacc506eec706ecf02cdbe74da5624648e7
|
|
| MD5 |
b2a367fd2e7725e12f305c12f8b057dc
|
|
| BLAKE2b-256 |
32b61c65c44986b8b92e82083baab09096f0d68f05327d8779f3996c99a90741
|