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

fix: query string included for the first collapsed path segment #1159

Merged
merged 1 commit into from
Apr 15, 2024

Conversation

mehdimas
Copy link
Contributor

@mehdimas mehdimas commented Apr 12, 2024

When the first path segment of a request has a query string the metrics middleware includes the query string in a collapsed path.

For example, /hello?uid=46cfcbdd-fd45-4fb2-a301-47bc24024b5c produces a metric like this:

ory_oathkeeper_requests_total{method="GET",request="hello?uid=46cfcbdd-fd45-4fb2-a301-47bc24024b5c",service="test",status_code="200"} 1

If the query string contains non-static values, then a new prometheus metric will be created for each request. The number of metrics increasing over time could cause stability issues.

The expected metrics should be a collapsed path like:

ory_oathkeeper_requests_total{method="GET",request="hello",service="test",status_code="200"} 1

This PR truncates any query string when collapsing the path.

Related issue(s)

Original metrics cardinality issue: #446

Checklist

  • I have read the contributing guidelines.
  • I have referenced an issue containing the design document if my change
    introduces a new feature.
  • I am following the
    contributing code guidelines.
  • I have read the security policy.
  • I confirm that this pull request does not address a security
    vulnerability. If this pull request addresses a security vulnerability, I
    confirm that I got the approval (please contact
    [email protected]) from the maintainers to push
    the changes.
  • I have added tests that prove my fix is effective or that my feature
    works.
  • I have added or changed the documentation.

Further Comments

The results of this issue are also visible in standard Oathkeeper Grafana dashboard:

Screenshot 2024-04-11 at 11 23 43 AM

@mehdimas mehdimas requested a review from aeneasr as a code owner April 12, 2024 15:19
@CLAassistant
Copy link

CLAassistant commented Apr 12, 2024

CLA assistant check
All committers have signed the CLA.

@mehdimas mehdimas force-pushed the metrics-remove-query-string branch from 9d99691 to 50e8616 Compare April 12, 2024 15:35
Copy link
Member

@aeneasr aeneasr left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Awesome, thank you!

@aeneasr aeneasr merged commit 15ee438 into ory:master Apr 15, 2024
21 checks passed
@mehdimas mehdimas deleted the metrics-remove-query-string branch April 15, 2024 14:30
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.

3 participants