ory / oathkeeper

A cloud native Identity & Access Proxy / API (IAP) and Access Control Decision API that authenticates, authorizes, and mutates incoming HTTP(s) requests. Inspired by the BeyondCorp / Zero Trust white paper. Written in Go.
https://www.ory.sh/?utm_source=github&utm_medium=banner&utm_campaign=hydra
Apache License 2.0
3.24k stars 357 forks source link

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

Closed mehdimas closed 5 months ago

mehdimas commented 5 months ago

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: https://github.com/ory/oathkeeper/issues/446

Checklist

Further Comments

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

Screenshot 2024-04-11 at 11 23 43 AM
CLAassistant commented 5 months ago

CLA assistant check
All committers have signed the CLA.