I just released a #Prometheus exporter for #mastodon that others may find useful:
https://github.com/andrew-d/mastodon_exporter

It currently supports metrics for number of local accounts, number of posts, number of resolved/unresolved mod reports, and a histogram of how long it took to resolve reports on the instance.

I'm planning to use it to graph the number of posts on our instance over time, and to set up alerting so that a new report doesn't get lost, along with tracking report SLAs to keep ourselves honest πŸ˜ƒ

This is my first time writing a Prometheus exporter, so feel free to submit PRs and I'd appreciate any feedback from those that do test it!

I run it on my Postgres database using something like:

DATABASE_URL="host=/var/run/postgresql user=mastodon database=mastodon" /path/to/mastodon_exporter --web.listen-address=localhost:9393

Boosts are appreciated to reach other Mastodon admins that may find this helpful.

#mastoadmin #monitoring

GitHub - andrew-d/mastodon_exporter: Prometheus metric to export data about a Mastodon instance

Prometheus metric to export data about a Mastodon instance - GitHub - andrew-d/mastodon_exporter: Prometheus metric to export data about a Mastodon instance

GitHub

For those interested: I'm using #Prometheus (https://prometheus.io/) and the #redis, #postgres, and node exporter to monitor various components of Mastodon and the servers I run, along with the #statsd exporter to gather Mastodon-specific metrics.

I'm also using the wonderful dashboards from @IPngNetworks with #grafana to visualize our instance's health; strongly recommend checking those out as well here:
https://ipng.ch/s/articles/2022/11/27/mastodon-3.html

Prometheus - Monitoring system & time series database

An open-source monitoring system with a dimensional data model, flexible query language, efficient time series database and modern alerting approach.

@andrew nice work, and thank you for the plug Andrew!
@andrew sweet! I look forward to checking this out tomorrow!
@tw Let me know if I can help with anything!

@andrew Can you please add a license to your repo? I can't contribute to an unlicensed repo. I'd like to try my hand at writing a Dockerfile and contributing it.

(Personally I'd prefer MIT or Apache but obviously it's your code so it's up to you of course.)

@tw D'oh! Sorry about that; added the Apache license.
@andrew Huh. I hadn’t looked much into Prometheus before. Looking at your repo, that’s more straightforward than I would have thought
@jamiemccarthy Yeah, I was pleasantly surprised how easy writing the exporter was! Running the Prometheus server is very straightforward, too.
@andrew have you successfully gotten any useful Grafana graphs out of the histogram metric you're exporting? I'm having a heck of a time getting it to do the right thing. (Not a ton of Grafana experience.)

@tw Yeah, I've got this graph; the JSON for Grafana is here:
https://gist.github.com/andrew-d/42eac6461e64dc9af5bee126ce1550d8

I'm also not a #grafana expert, in fairness πŸ˜…

Demo graph for https://github.com/andrew-d/mastodon_exporter

Demo graph for https://github.com/andrew-d/mastodon_exporter - grafana-graph.json

Gist
@andrew now I just have to figure out how to import a panel by JSON... 🀣
@andrew aha, found it, Inspect -> Panel JSON, which of course allows you to modify as well.
@tw Ah, beat me to it. I just copy-pasted that bit from the JSON export of the entire graph. Thanks!
@andrew what's "fun" is that it now looks right in the panel edit view but it's not showing up correctly on the dashboard. May just have to re-create it based on this, I suspect something in the JSON copy/paste went wonky.
@andrew literally just doing a panel duplicate made it work. So I guess something weird in the C&P was happening probably as I suspected.

@andrew Awesome! Would love to see this stats for my instance πŸ’œ

Any chance we could have documentation on how to implement it non-docker? Like how to create the service, etc I've set up my current monitoring following this https://jaanus.com/mastodon-monitoring-prometheus-grafana/

The docs could also have the JSON panel for #Grafana I saw in this thread πŸ™

How to set up monitoring for your Mastodon instance with Prometheus and Grafana – Jaanus