by dboreham · 3y ago · 0 comments
This is the library to use in your python code to expose metrics so that Prometheus can scrape them. The diagram would definitely be useful, it started as something that "you already knew if you need it" but I noticed that there is more interest from people with no experience with these system, I was considering adding more information or making small guides/tutorial to ease into the why you need the monitoring, even for small applications since the price is small. Thanks!
I believe these are typically called "exporters". They implement servers that Prometheus scrapes. The quote "if you had issues while using multiprocess in python when collecting metrics this might interest you" suggests this is what this is. I've used [1] in the past, including for collecting across multiple processes with multiprocessing, and didn't really have any problems beyond my usual issues with Prometheus.
[1]: github.com/prometheus/client_python
If you didn't have issues with multiprocessing that's great, but it seems like it's not uncommon for people to have issues with that approach, for example (the reason I started to experiment on this as a sideproject) in the k6 team at grafana we had the problem of too many files getting created and not properly getting cleaned up, we were forced to go into single process mode and with kubernetes that's fine. But if you are not running in kubernetes, I'm not sure you had a clean alternative :)
The target was clear, people that had issues with multiprocessing with the current ecosystem.
But as I noticed the interest growing, I also noticed a lack of simple guides on how to go from zero to have graphs in grafana for your metrics. That's why I started the "tutorial" section in the docs (pythe.us) initially for FastAPI to try to fill that void. I'm also considering making a full video tutorial to complement it.
So to recap, here I'm sharing the existence of this project so I can hopefully gather some feedback for the future direction. For beginners right now there is the "Quickstart" section in the documentation that guides you through monitoring latency in a flask application. It does not cover how to setup prometheus yet but I'm sure the prometheus docs can help with that for now :)