Installation
pip install discord-ext-prometheus
Exposed Metrics
| Name | Documentation | Labels |
|---|---|---|
discord_connected |
Determines if the bot is connected to Discord | None |
discord_event_on_interaction |
Amount of interactions | command |
discord_event_on_command |
Amount of commands | command |
discord_stat_total_guilds |
Amount of guild this bot is a member of | None |
discord_stat_total_channels |
Amount of channels this bot is has access to | None |
discord_stat_total_users |
Amount of users this bot can see | None |
discord_stat_total_commands |
Amount of commands | None |
logging |
Log entries | logger, level |
Notes:
on_interactionare application interactions such as slash commandson_commandare traditional message commands (usualy using the command prefix)
Grafana Dashboard
TODO
How to use
Once the cog is added to your bot, the Prometheus metric endpoint can be accessed
at localhost:8000/metrics.
Sample code with the Prometheus Cog
from discord.ext.prometheus import *
async def main():
bot = commands.Bot(
command_prefix='!',
intents=Intents.all(),
)
await bot.add_cog(PrometheusCog(bot))
await bot.start('YOUR TOKEN')
asyncio.run(main())
Sample code with logging metrics
from discord.ext.prometheus import *
import logging
logging.getLogger().addHandler(PrometheusLoggingHandler())
async def main():
bot = commands.Bot(
command_prefix='!',
intents=Intents.all(),
)
await bot.add_cog(PrometheusCog(bot))
logging.info('Starting the bot')
await bot.start('YOUR TOKEN')
@bot.listen()
async def on_ready():
logging.info(f'Logged in as {bot.user.name}#{bot.user.discriminator}')
asyncio.run(main())
Change the Prometheus port
The default port is 8000 but can be changed while creating the cog.
await bot.add_cog(PrometheusCog(bot, port=7000))
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 discord_ext_prometheus-0.0.1.tar.gz.
File metadata
- Download URL: discord_ext_prometheus-0.0.1.tar.gz
- Upload date:
- Size: 5.9 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.2 CPython/3.10.8
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
700d93ee15b754471389bef2066f054147c9e5099ef81b4e13acfcc9970632bf
|
|
| MD5 |
a3e35b4e7cc23ca0fb5ba7230778745e
|
|
| BLAKE2b-256 |
2ea352ffa9542feaec222504b15c80a8a9a5b8498f7a050c7dafbf4d35ffd08b
|
File details
Details for the file discord_ext_prometheus-0.0.1-py3-none-any.whl.
File metadata
- Download URL: discord_ext_prometheus-0.0.1-py3-none-any.whl
- Upload date:
- Size: 5.0 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.2 CPython/3.10.8
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
5eb9c6122d19cee3a2e4a8f1cec47f2c505e987d0255ebb74414287acadc8ad7
|
|
| MD5 |
b57b5cddbefa4cccb8fafc0d54e81cf7
|
|
| BLAKE2b-256 |
d25a0f37e4873884aa9d2eecec339f10ed6a0d2311a580ab4e190ba750cc6869
|