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

More Customizable collapse_request_path Setting #1212

Open
5 tasks done
WillyRL opened this issue Dec 30, 2024 · 3 comments
Open
5 tasks done

More Customizable collapse_request_path Setting #1212

WillyRL opened this issue Dec 30, 2024 · 3 comments
Labels
feat New feature or request.

Comments

@WillyRL
Copy link

WillyRL commented Dec 30, 2024

Preflight checklist

Ory Network Project

No response

Describe your problem

In reference to issue #446, the collapse_request_path configuration could be significantly more useful if it were more flexible.

Use Case
I have an /api prefix for my service, followed by a unique UUID in the URL path, for example:

/api/conversations/{uuid-v4-conversation-id}/messages

When collapse_request_path is set to false, my metrics become unmanageable because each unique UUID generates a separate metric entry. However, setting it to true collapses everything under the /api prefix, losing valuable details for different endpoints.

Describe your ideal solution

Enable a more advanced configuration for collapse_request_path that allows specifying patterns, placeholders, or partial collapsing so that important segments (like /conversations) are preserved while unique identifiers (UUIDs) are collapsed.

Example Configuration

  collapse_request_paths:
    enabled: true
    rules:
      - pattern: "^/api/conversations/[0-9a-fA-F-]{36}/messages"
        replacement: "/api/conversations/:conversationId/messages"
      - pattern: "^/api/other-service/[0-9a-fA-F-]{36}"
        replacement: "/api/other-service/:resourceId"

Workarounds or alternatives

If the pattern based is too complicated, for the use case that using /api prefix, provide the collapse_level.

  collapse_request_paths:
    enabled: true
    # Define how many path segments to skip from the start
    collapse_level: 1

Version

0.40.6

Additional Context

No response

@WillyRL WillyRL added the feat New feature or request. label Dec 30, 2024
@aeneasr
Copy link
Member

aeneasr commented Jan 2, 2025

Let me loop in @nipsufn to take a look at this idea as he is working on this issue in our system as well right now.

@nipsufn
Copy link
Contributor

nipsufn commented Jan 7, 2025

I think you should be able to do that with Prometheus relabelings.

PR is welcome with changes on code level.
There's a similar solution already used in Kratos with ory/x/prometheusx, maybe it can be reused or at least serve as a starting point.

@WillyRL
Copy link
Author

WillyRL commented Jan 10, 2025

I think you should be able to do that with Prometheus relabelings.

yes, I think so. But I also think it's a bad Idea to let all the request path exposed on /metrics, it will introduce performance issues when the requests path are keep growing, at least the performance when the prometheus try to fetching the metrics.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feat New feature or request.
Projects
None yet
Development

No branches or pull requests

3 participants