Grafana
The repository has a Grafana dashboard for @shardlens/exporter-prometheus:
deploy/grafana/shardlens-dashboard.json.
It works the same with @shardlens/exporter-otel when the metrics reach Prometheus through an OpenTelemetry Collector,
which gives them the same names.
- Add the exporter to your bot and point Prometheus at it, as in Exporter only.
- In Grafana, open Dashboards → New → Import and upload
shardlens-dashboard.json. - At the top of the dashboard, pick your Prometheus data source (it starts on the default one) and, if Prometheus scrapes more than one bot, the Job of the bot to show. All adds up every job.
To provision it instead, put the file in a folder Grafana reads dashboards from:
apiVersion: 1providers: - name: shardlens type: file options: path: /var/lib/grafana/dashboards # holds shardlens-dashboard.jsonWhat’s on it
Section titled “What’s on it”- Headline stats: interactions per second, the share that failed, missed the deadline or got no response, p95 response time against the 3-second deadline, and how much of the invalid-request budget the last 10 minutes used.
- Interactions: by command and by outcome, response-time percentiles, handler errors by class, and the slowest handlers by command.
- REST: requests by status, the busiest routes, rate-limit waits by scope, and invalid requests by status.
- Gateway: ping per shard, servers per shard and in total, shard state changes, servers joined and left, and the identify budget.
- Process: event loop delay, memory, discord.js cache sizes, and your custom events.
Components and modals with no command behind them are shown as (none).
Alerts worth setting
Section titled “Alerts worth setting”| Alert | PromQL |
|---|---|
| Missed or unanswered interactions > 1% | sum(rate(shardlens_interactions_total{outcome=~"timeout|no_response"}[10m])) / sum(rate(shardlens_interactions_total[10m])) > 0.01 |
| Invalid-request budget > 50% | sum(increase(shardlens_rest_invalid_requests_total[10m])) > 5000 |
| Shards reconnecting | sum by (shard) (increase(shardlens_shard_events_total{state=~"reconnecting|invalidated"}[15m])) > 3 |
| The bot stopped answering scrapes | up{job="discord-bot"} == 0 |