dcexport is a Prometheus exporter to track information about Discord guilds using a Discord bot. Unlike many other available exporters, this exporter is written in Rust for increased stability with minimal runtime resource requirements.
dcexport provides the following metrics. Every metric uses the label guild_id
to differentiate the different guilds.
For more detailed information about the metrics and their labels, see the source code.
Name | Description | Type |
---|---|---|
guild | The number of guilds handled by the exporter. | Gauge |
message_sent | The total number of discord messages sent by guild members. | Counter |
emote_used | The total number of discord emotes reacted with by guild members in messages. | Counter |
activity | The number of current activities. | Gauge |
member | The number of members (including bots) on the guild. | Gauge |
bot | The number of bot members on the guild. | Gauge |
member_status | The number of members on the guild per status. | Gauge |
member_voice | The number of members in voice channels. | Gauge |
boost | The number of boosts active on the guild. | Gauge |
channel | The number of channels on the guild. Used for injecting channel names into other metrics. | Gauge |
Warning
While dcexport is stable, please view the individual releases for any version-specific details that need to be considered while deploying. Changes are performed in adherence to Semantic Versioning.
Before any Discord guilds can be tracked, we first need to set up dcexport on the corresponding machine. The application is configured using the cli or environment variables.
Env Variable | Default | Description |
---|---|---|
DISCORD_TOKEN | (required) | The token of the Discord bot that is on the guilds that should be exported. |
LOG_LEVEL | dcexport=info | The log filter configuration of the application. See here for more information. |
ADDRESS | 0.0.0.0:10030 | The metrics server address. |
To run dcexport from a binary file, download the appropriate binary from our releases, make it executable and run it within the shell of your choice:
chmod +x dcexport
./dcexport --discord-token <your-token>
To run dcexport within Docker, we can use the images that we release within our Container Registry. Those images are hardened and provide the optimal environment to execute dcexport in a containerized environment.
docker run --rm \
-e DISCORD_TOKEN=<your-token> \
-p 10030/tcp \
--name dcexport \
ghcr.io/scrayosnet/dcexport:latest
There's currently no public Helm Chart for dcexport. We're open for contributions! In the meantime, you can create your own deployment using Kustomize or any other tooling of your choice.
To verify whether everything works as expected, we can invoke the following command on the same machine and observe the reported result:
curl --request GET -sL --url 'http://localhost:10030/'
If the result shows any metrics, dcexport is now setup successfully and can be used to track Discord guilds.
Now that dcexport is working as expected, we need to configure Prometheus to track any Discord guilds. Depending on the individual setup, this can be done in one of those ways:
In a normal (non-Kubernetes) deployment of Prometheus, we can track any Discord guild with a scrape configuration like this:
scrape_configs:
- job_name: "dcexport"
scrape_interval: 60s
scrape_timeout: 30s
metrics_path: /metrics
scheme: http
static_configs:
- targets:
- dcexport:10030
Assuming, there's a namespace dcexport
with a deployment of dcexport, and a corresponding service dcexport
is in
that namespace, that exposes the dcexport instances internally, we can track metrics with this CRD configuration
using the ServiceMonitor resource:
apiVersion: monitoring.coreos.com/v1
kind: ServiceMonitor
metadata:
name: dcexport
namespace: dcexport
spec:
endpoints:
- port: metrics
path: /metrics
interval: 30s
Depending on your setup, you may also need to add a label, so that the configuration is picked up by your Prometheus
instance. If you've installed it through the kube-prometheus-stack
helm chart, it could, for example, be
release: kube-prometheus-stack
. You can check the required labels in your Prometheus CRD.
To report a security issue for this project, please note our Security Policy.
Participation in this project comes under the Contributor Covenant Code of Conduct.
Thanks for considering contributing to this project! In order to submit a Pull Request, please read our contributing guide. This project is in active development, and we're always happy to receive new contributions!
This project is developed and distributed under the MIT License. See this explanation for a rundown on what that means.