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

Add new http default metrics #65

Open
ivan-tymoshenko opened this issue Oct 5, 2022 · 5 comments
Open

Add new http default metrics #65

ivan-tymoshenko opened this issue Oct 5, 2022 · 5 comments

Comments

@ivan-tymoshenko
Copy link

ivan-tymoshenko commented Oct 5, 2022

@SkeLLLa What do you think about adding new HTTP-related default metrics like total req count, req per sec, req per min, failure req count?

You already have a lot of what it takes to support these metrics: ignoring http methods/routes, subscriptions on fastify hooks, gathering status codes, etc.

@SkeLLLa
Copy link
Owner

SkeLLLa commented Oct 5, 2022

Hi. Do you mean "total" in general, not per route?

In general all those metrics are available through Prometheus query.
Total req count is part of histogram and summary. So you can do sum(http_request_summary_seconds_count). Same for failed, but with filter by status code label: sum(http_request_summary_seconds_count) by (status_code).

For rps/rpm you can use rate function alongside with the same counter.

Do those promql calculations cover your case? Or you have something specific?

@ivan-tymoshenko
Copy link
Author

My case (platformatic) is specific, but it doesn't matter. Actually, you're right. Especially about rate metrics.

If we talk about metrics like failure rate, I will have to specify all possible successful status codes and all failure status codes in the prom request. I thought it could be done much simpler in the code. WDYT?

@SkeLLLa
Copy link
Owner

SkeLLLa commented Oct 7, 2022

@ivan-tymoshenko for error codes, there's an option to group them https://github.com/SkeLLLa/fastify-metrics/blob/master/docs/fastify-metrics.iroutemetricsconfig.groupstatuscodes.md.

Also you can use regex syntax in promql label matching.

@ivan-tymoshenko
Copy link
Author

groupStatusCodes metrics aggregate all requests for one endpoint, but what if I want to get info for all requests. For example get request time in quantiles for all requests or for all successful requests.

@SkeLLLa
Copy link
Owner

SkeLLLa commented Oct 12, 2022

If I understood correctly, you can use https://prometheus.io/docs/prometheus/latest/querying/functions/#histogram_quantile
In other words you get the data from histogram, do sum by successful codes and use histogram_quantile.

Does this cover your case?

PS: Btw, those cases you've described above could be a part of docs for this repo, e.g. we can add some "how-to" recopies.

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