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

Really basic implementation of a metrics target for use by prometheus #275

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

jelmer
Copy link
Contributor

@jelmer jelmer commented Jan 8, 2022

Really basic implementation of a metrics target for use by prometheus.

Some caveats:

  • this exposes /metrics on the same port as the rest of klaus;
    one might not want to expose internal metrics there
  • this doesn't yet add any really useful metrics
    (number of requests, failures, exceptions, etc). At the moment
    it just exports a bunch of python statstics.

@jonashaag
Copy link
Owner

I wonder if this could be implemented as a WSGI middleware? (Maybe there already exists some pluggable WSGI middleware that we can just use?)

@jonashaag
Copy link
Owner

@jelmer
Copy link
Contributor Author

jelmer commented Jan 8, 2022

It can't be just middleware if you want to add klaus-specific metrics, and those are the most useful.

client_python (the second in your list) is what I'm using in this PR

@jonashaag
Copy link
Owner

Sure, at least we will have to provide some hooks in the Klaus codebase or we can push metrics from Klaus (eg. increase some counters from Klaus views).

I was wondering more about the metrics endpoint. I wonder if it makes sense to use Prometheus-Flask-Exporter or something like this: https://github.com/prometheus/client_python#flask

But I am fine with a stand-alone implementation if you think that’s easier. I wonder if we should make the feature optional even if prometheus_client is installed.

@jelmer
Copy link
Contributor Author

jelmer commented Oct 16, 2022

Maybe the best approach here is to have a separate port for the metrics. That's consistent with what other web apps do - so you don't have your metrics exposed to the internet. The other benefit is that we can then only import the metrics library when --metrics-port is specified.

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

Successfully merging this pull request may close these issues.

None yet

2 participants