Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Collect metrics on scrape instead of timer #1059

Open
nonamethanks opened this issue Oct 3, 2024 · 1 comment
Open

Collect metrics on scrape instead of timer #1059

nonamethanks opened this issue Oct 3, 2024 · 1 comment

Comments

@nonamethanks
Copy link

nonamethanks commented Oct 3, 2024

The prometheus docs on exporters say:

Metrics should only be pulled from the application when Prometheus scrapes them, exporters should not perform scrapes based on their own timers. That is, all scrapes should be synchronous.

The very first example provided by this repository goes against those docs by just spamming the same function on a timer.

Can anyone provide a basic example that shows how to start a metrics collection only when prometheus connects to the exporter, as it's actually supposed to be done? Because christ, it's faster to just set up a flask server with a custom /metrics endpoint than actually figure out how to do so using this framework.

@csmarchbanks
Copy link
Member

If you are interested in creating an exporter see the custom collectors section of the docs: https://prometheus.github.io/client_python/collector/custom/.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants