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

Adds the optional ability to split the tenant request header by comma #223

Conversation

csthomas1
Copy link
Contributor

@csthomas1 csthomas1 commented Jun 6, 2024

Currently, prom-label-proxy will accept multiple header values only if they correspond to separately-occurring header lines in the incoming HTTP request. Example request:

GET /api/v1/query?query=up HTTP/1.1
Host: localhost:9090
User-Agent: curl/7.68.0
X-Tenant: firsttenant
X-Tenant: secondtenant
Accept: */*

Attempting to pass multiple header values via list-style syntax as described in RFC 9110 (https://www.rfc-editor.org/rfc/rfc9110#name-field-lines-and-combined-fi), on the other hand, results in a single tenant value consisting of the entire comma-separated string. Example request:

GET /api/v1/query?query=up HTTP/1.1
Host: localhost:9090
User-Agent: curl/7.68.0
X-Tenant: firsttenant, secondtenant
Accept: */*

With the above sample request, the tenant label match expression becomes "firsttenant, secondtenant"

This is inconvenient for use with Custom Header configuration on Grafana Data Sources, which seem to be unable to pass more than one request header line for a given header name -- the last header value overwrites the first.

This pull request adds OPTIONAL support for parsing the tenant request header as a comma-separated list. To enable, add the parameter "-header-uses-list-syntax" to the prom-label-proxy's commandline.

When the list syntax option enabled, the sample request containing the "firsttenant, secondtenant" list given above ultimately produces the tenant label match expression "firsttenant|secondtenant".

@csthomas1 csthomas1 force-pushed the split-request-header-param-by-comma branch from 9041f71 to 5acaa7d Compare June 6, 2024 15:18
@csthomas1 csthomas1 force-pushed the split-request-header-param-by-comma branch from 5acaa7d to 6ef52fd Compare June 6, 2024 18:56
Copy link
Contributor

@simonpasquier simonpasquier left a comment

Choose a reason for hiding this comment

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

Thanks!

@simonpasquier simonpasquier merged commit 9c8a470 into prometheus-community:main Jun 7, 2024
4 checks passed
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.

2 participants