Skip to content

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

Open
jelmer wants to merge 1 commit into
jonashaag:masterfrom
jelmer:metrics
Open

Really basic implementation of a metrics target for use by prometheus#275
jelmer wants to merge 1 commit into
jonashaag:masterfrom
jelmer:metrics

Conversation

@jelmer

@jelmer jelmer commented Jan 8, 2022

Copy link
Copy Markdown
Contributor

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
Copy Markdown
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
Copy Markdown
Owner

@jelmer

jelmer commented Jan 8, 2022

Copy link
Copy Markdown
Contributor Author

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
Copy Markdown
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

jelmer commented Oct 16, 2022

Copy link
Copy Markdown
Contributor Author

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.

2 participants