Prometheus Extension for Discord.py

By ApolloRoboto | Published ()

Python Discord Prometheus Grafana Library PyPi Analytics Bot Extension Metrics Open Source

Originally created in 2022

As I was on a DevOps team at the time, I wanted to put the Prometheus metrics into everything. I had to make one for my own Discord bot

Implementation

This was built for the discord.py library. I made it as easy as possible to add, being inspired from other similar extensions, it’s a simple cog that you can add with add_cog().

import os
import asyncio
from discord.ext import commands
from discord.ext.prometheus import PrometheusCog

async def main():
	bot = commands.Bot(
		command_prefix="!",
		intents=Intents.all(),
	)

	await bot.add_cog(PrometheusCog(bot))

	await bot.start(os.environ["DISCORD_TOKEN"])

if __name__ == "__main__":
	asyncio.run(main())

And from there, your metrics are accessible at localhost:8000/metrics

Grafana

Grafana Dashboard

The grafana dashboard shows a bunch of overall metrics:

  • Many discord bot support.
  • All called commands, including buttons and other Discord interactions.
  • Stats like the amount of users and servers each bot sees.
  • Up time and connection status with latency.
  • Logs rate (optional)

So it has all to get a good overview on how your bots are doing.

GitHub Icon

Copyright © 2026 | ApolloRoboto

(。◕‿‿◕。)

Powered by Github Pages, Hugo and Tailwindcss