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.
Configuration
Constructor kwargs override ARGUS_* environment variables override defaults.
| kwarg | env | default | meaning |
|---|---|---|---|
port |
ARGUS_PORT |
9191 |
server port |
host |
ARGUS_HOST |
0.0.0.0 |
bind host |
metrics_path |
ARGUS_METRICS_PATH |
/metrics |
metrics endpoint |
cluster_id |
ARGUS_CLUSTER_ID |
default |
low-cardinality label for clustered deploys |
namespace |
ARGUS_NAMESPACE |
discord |
metric name prefix |
dashboard |
ARGUS_DASHBOARD |
true |
serve the dashboard at / |
dashboard_path |
ARGUS_DASHBOARD_PATH |
/ |
dashboard mount path |
dashboard_interval |
ARGUS_DASHBOARD_INTERVAL |
5 |
live-stream seconds |
dashboard_auth_token |
ARGUS_DASHBOARD_AUTH_TOKEN |
— | bearer token gating the dashboard + APIs |
grafana_url |
ARGUS_GRAFANA_URL |
— | link/embed your Grafana boards |
enable_per_guild |
ARGUS_ENABLE_PER_GUILD |
false |
enable the per-guild analytical path |
clickhouse_dsn |
ARGUS_CLICKHOUSE_DSN |
— | ClickHouse sink/target for analytics |
otlp_endpoint |
ARGUS_OTLP_ENDPOINT |
— | also push metrics via OTLP |
Full reference: Configuration.
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.0.tar.gz.
File metadata
- Download URL: argus_dpy-0.3.0.tar.gz
- Upload date:
- Size: 194.7 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
945ee5cef60638c0c2e24a18aa6264b03af36e737ed8615e37edaacbb11e1f44
|
|
| MD5 |
ba1bd70904eadd37b8aab2d123ab265c
|
|
| BLAKE2b-256 |
21d395d655184466d7b214a872dd8fbcce3de86d476da9b394459affe72320be
|
Provenance
The following attestation bundles were made for argus_dpy-0.3.0.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.0.tar.gz -
Subject digest:
945ee5cef60638c0c2e24a18aa6264b03af36e737ed8615e37edaacbb11e1f44 - Sigstore transparency entry: 1881875254
- Sigstore integration time:
-
Permalink:
AstorisTheBrave/argus@48ffb33a70ca86099bbfc633361bed496e54198e -
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@48ffb33a70ca86099bbfc633361bed496e54198e -
Trigger Event:
push
-
Statement type:
File details
Details for the file argus_dpy-0.3.0-py3-none-any.whl.
File metadata
- Download URL: argus_dpy-0.3.0-py3-none-any.whl
- Upload date:
- Size: 232.3 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 |
a9740c8e0d6070dc7ba909854def3f3b41ae3a8721c352610e589000a071558d
|
|
| MD5 |
7e0552a089fdaf595b6400de5a444655
|
|
| BLAKE2b-256 |
941e09a44e68cb881f9001d5b5056568111faa31e6b27cb610975705103264e3
|
Provenance
The following attestation bundles were made for argus_dpy-0.3.0-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.0-py3-none-any.whl -
Subject digest:
a9740c8e0d6070dc7ba909854def3f3b41ae3a8721c352610e589000a071558d - Sigstore transparency entry: 1881875392
- Sigstore integration time:
-
Permalink:
AstorisTheBrave/argus@48ffb33a70ca86099bbfc633361bed496e54198e -
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@48ffb33a70ca86099bbfc633361bed496e54198e -
Trigger Event:
push
-
Statement type: