Operational Prometheus/OpenTelemetry metrics for discord.py bots, in one line.
Project description
argus-dpy
Operational Prometheus / OpenTelemetry metrics for discord.py bots, in one line.
from discord.ext import commands
from argus import Argus
bot = commands.AutoShardedBot(command_prefix="!", intents=...)
Argus(bot) # the whole integration
Argus(bot) instruments shard latency, interaction/command throughput and
outcomes, precise command duration, gateway throughput, rate-limit pressure and
cache sizes, then serves a Prometheus /metrics endpoint and a live web
dashboard on the bot's own event loop. It can also push to OpenTelemetry and
drain per-guild events to ClickHouse. It never puts a guild, user, or channel id
on a Prometheus label.
Install
pip install argus-dpy
Python 3.10+, discord.py >= 2.4. Optional extras: argus-dpy[otlp],
argus-dpy[clickhouse]. A reference container is published at
ghcr.io/astoristhebrave/argus.
Behaviour
Argus(bot) registers listeners synchronously, then starts an aiohttp server on
the bot's loop once it is running. By default it serves the dashboard at /
and metrics at /metrics on port 9191. Disable the dashboard with
Argus(bot, dashboard=False); everything else is opt-in. Instrumentation is
fail-open: it is counted and swallowed, never raised into your bot.
See Architecture & invariants.
Minimal setup
The minimum is one line; everything else is opt-in via kwargs or ARGUS_*
environment variables (kwargs override env override defaults).
Argus(bot) # metrics at /metrics, dashboard at /, on port 9191
To protect the dashboard, set one env var on the host that runs the bot — Argus picks it up automatically. The dashboard is served by Argus in the same process, so there is nothing separate to host or wire up:
ARGUS_DASHBOARD_AUTH_TOKEN=your-secret # gates / and /api/*; /metrics stays scrapeable
Open the dashboard once with the token and it is remembered in the browser:
http://your-host:9191/?token=your-secret.
Common options
| kwarg / env | default | meaning |
|---|---|---|
port / ARGUS_PORT |
9191 |
server port |
dashboard_auth_token / ARGUS_DASHBOARD_AUTH_TOKEN |
— | gate the dashboard + APIs |
grafana_url / ARGUS_GRAFANA_URL |
— | link/embed your Grafana boards |
cluster_id / ARGUS_CLUSTER_ID |
default |
label for clustered deploys |
enable_per_guild / ARGUS_ENABLE_PER_GUILD |
false |
per-guild analytics path |
otlp_endpoint / ARGUS_OTLP_ENDPOINT |
— | also push metrics via OTLP |
Every option, precedence and parsing rule is in Configuration. New here? Start with the FAQ.
Metrics
Aggregate, bounded-cardinality metrics: per-shard latency and up state,
per-cluster guild/user/voice/emoji/sticker/channel counts, uptime, registered
commands, interaction and command rates with success/error split, precise
command-duration histogram, gateway throughput, shard dis/reconnects, log and
rate-limit counters. Every counter and the histogram carry a cluster label.
Full list with labels: Metrics Reference.
Dashboard
A React SPA bundled into the wheel, served at /: overview, interactions,
gateway, your Grafana boards, and per-guild analytics. Reads metrics live over
SSE with a polling fallback. Set dashboard_auth_token for anything public.
See Dashboard.
Per-guild analytics
Per-guild, per-user questions never go to Prometheus (cardinality). With
enable_per_guild + clickhouse_dsn, Argus drains per-guild events to
ClickHouse (batched, non-blocking) and the dashboard's Analytics section serves
per-guild command counts and average durations.
See History & ClickHouse.
Grafana, OTLP, clustering
docker compose up -d brings up a provisioned Prometheus + Grafana with three
dashboards. Set otlp_endpoint to also push via OpenTelemetry. Run one Argus
per process with a distinct cluster_id for clustered bots.
See Clustering and
OTLP.
Why no per-guild Prometheus labels?
guild_id/user_id/channel_id are unbounded; as labels they explode
Prometheus at scale and are useless to visualise. Argus forbids them by
construction and routes per-entity questions to the analytical path instead.
Contributing & license
Contributions are accepted under the DCO; see CONTRIBUTING.md. Licensed under AGPL-3.0-or-later (network use counts as distribution) — see LICENSE.
See the full wiki for the in-depth guides and explanations.
Project details
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 argus_dpy-0.3.1.tar.gz.
File metadata
- Download URL: argus_dpy-0.3.1.tar.gz
- Upload date:
- Size: 195.0 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
ac6fadfd2393c2526af4b7b22f28f321807a2914f5ad6c8ac068524ea79110fe
|
|
| MD5 |
3884ea53004fee88258e1a10ae2d0f94
|
|
| BLAKE2b-256 |
d7407be6edb0c20b12c395fc2513de8de77aed3408052fdaa89b42c998f50ba6
|
Provenance
The following attestation bundles were made for argus_dpy-0.3.1.tar.gz:
Publisher:
release-please.yml on AstorisTheBrave/argus
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
argus_dpy-0.3.1.tar.gz -
Subject digest:
ac6fadfd2393c2526af4b7b22f28f321807a2914f5ad6c8ac068524ea79110fe - Sigstore transparency entry: 1882390441
- Sigstore integration time:
-
Permalink:
AstorisTheBrave/argus@121962b1d03804374dad1d4c53e4a32c13fa274d -
Branch / Tag:
refs/heads/main - Owner: https://github.com/AstorisTheBrave
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release-please.yml@121962b1d03804374dad1d4c53e4a32c13fa274d -
Trigger Event:
push
-
Statement type:
File details
Details for the file argus_dpy-0.3.1-py3-none-any.whl.
File metadata
- Download URL: argus_dpy-0.3.1-py3-none-any.whl
- Upload date:
- Size: 232.4 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
fb8f5ed1b2f753bf38a4bcdda09bc57663b14651f34a5ca58a9d58a635089d0e
|
|
| MD5 |
698db6fc54e4dc532269ccddb7dd0121
|
|
| BLAKE2b-256 |
5280552478388022eb5e8fda3ac9d7cd1950a22563c5b5ef0ee08bfda7130df7
|
Provenance
The following attestation bundles were made for argus_dpy-0.3.1-py3-none-any.whl:
Publisher:
release-please.yml on AstorisTheBrave/argus
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
argus_dpy-0.3.1-py3-none-any.whl -
Subject digest:
fb8f5ed1b2f753bf38a4bcdda09bc57663b14651f34a5ca58a9d58a635089d0e - Sigstore transparency entry: 1882390619
- Sigstore integration time:
-
Permalink:
AstorisTheBrave/argus@121962b1d03804374dad1d4c53e4a32c13fa274d -
Branch / Tag:
refs/heads/main - Owner: https://github.com/AstorisTheBrave
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release-please.yml@121962b1d03804374dad1d4c53e4a32c13fa274d -
Trigger Event:
push
-
Statement type: