Skip to content

Collect metrics on scrape instead of timer #1059

Description

@nonamethanks

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.

Activity

  1. csmarchbanks commented on Oct 8, 2024

    @csmarchbanks
    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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions