Mediabot can now expose Prometheus metrics and be monitored cleanly in Grafana.
The goal is simple:
This post provides a simple and reusable base for the community, with:
In mediabot.conf, add:
[metrics]
METRICS_ENABLED=1
METRICS_BIND=127.0.0.1
METRICS_PORT=9108
127.0.0.1 is perfect if Prometheus runs on the same machine as Mediabot0.0.0.0, and proper firewall filteringOnce the bot has been restarted, you should be able to verify this:
curl http://127.0.0.1:9108/metrics
The dashboard relies on metrics such as:
mediabot_upmediabot_build_infomediabot_irc_connectedmediabot_db_connectedmediabot_channels_managedmediabot_uptime_secondsmediabot_commands_public_totalmediabot_commands_private_totalmediabot_commands_partyline_totalmediabot_channel_lines_in_totalmediabot_channel_commands_totalmediabot_channel_commands_by_name_totalmediabot_rehash_totalmediabot_restart_totalmediabot_jump_totalmediabot_auth_success_totalmediabot_auth_failure_totalmediabot_partyline_sessions_currentmediabot_partyline_logins_totalHere is a simple example for a single bot:
scrape_configs:
- job_name: "mediabot"
scrape_interval: 15s
metrics_path: /metrics
static_configs:
- targets:
- "127.0.0.1:9108"
labels:
service: "mediabot"
instance_name: "mediabot"
After editing the configuration, verify it and reload Prometheus:
promtool check config /path/to/prometheus.yml
curl -X POST http://127.0.0.1:9090/-/reload
Quick check in Prometheus:
mediabot_up
If everything is fine, the query should return 1.
The generic dashboard provided here is designed to be:
For the community, the most useful entry point is a dashboard that works immediately with:
A multi-instance variant is obviously possible later, but it should not be the default entry point.
When several bots are deployed, you only need to add more targets in Prometheus, each with its own instance_name.
Example:
scrape_configs:
- job_name: "mediabot"
scrape_interval: 15s
metrics_path: /metrics
static_configs:
- targets: ["127.0.0.1:9108"]
labels:
service: "mediabot"
instance_name: "bot-main"
- targets: ["bot2.example.org:9108"]
labels:
service: "mediabot"
instance_name: "bot2"
With a small set of well-chosen metrics, Prometheus and Grafana provide a much clearer view of:
It is clean, standard, easy to extend, and far more comfortable than relying only on logs.
grafana_mediabot_community_single_bot_v2.jsonYou must be logged in to reply.