-
-
Notifications
You must be signed in to change notification settings - Fork 1.5k
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
fix: Prometheus URL label #2503
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is great! I think we can merge it as is. My only question would be - is it normal to remove these params? I guess you would use tracing to find actual slow queries, not prometheus?
Do you want this to be merged already or do you want to address the known issues first? Not to self (release log):
|
Right, Prometheus is a monitoring tool, and it should not collect data for all unique requested URLs, so my solution is acceptable.
Until we start to use a more powerful router, known issues can't be fixed. So let's proceed and merge it. Thank you. |
I believe that var rw http.ResponseWriter
res := rw.(negroni.ResponseWriter)
status := res.Status()
size := res.Size() I also saw your PR in Ory Kratos - thank you! I would say we put the contents of https://github.com/ory/kratos/tree/4b4032681dc177bb2811684c5858844a69f2bb1d/metrics/prometheus into What do you think? |
I will experiment with status codes next week, and see how I can improve existing metrics. It would be nice to add counters per status code per endpoint. |
Submitted the PR that refactors the code. For status codes, I will create a separate ticket/feature request. |
The changes in ory/x are published as https://github.com/ory/x/releases/tag/v0.0.237 |
@@ -1,26 +0,0 @@ | |||
package prometheus |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@aeneasr what should I do with this file?
Awesome, thank you! :) |
Related issue
Fixes #2502
Proposed changes
Because an existing HTTP router library does not register in Context object any valuable information that can be used for determining whether URL was matched or not, routers need to be registered in
MetricsManager
directly and all requests need to be matched a second time. Once the request URL is matched to any of the endpoints in any of the registered routers, middleware emits a metric with a value equal to the path, otherwise label{unmatched}
is used. All matched parameters in the path are getting replaced by{param}
in the metric label, so:/clients/12345
and/clients/randomString
with emit an event with label/clients/{param}
Known issues:
/clients/clients
can be matched with endpoint/clients/:id
, and reconstruction logic would replace all stringsclients
to{param}
.Checklist
vulnerability. If this pull request addresses a security. vulnerability, I
confirm that I got green light (please contact
security@ory.sh) from the maintainers to push
the changes.
works.
Further comments