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

Log value of arbitrary request headers in query frontend stats log #11422

Closed
jmichalek132 opened this issue Dec 9, 2023 · 0 comments · Fixed by #11499
Closed

Log value of arbitrary request headers in query frontend stats log #11422

jmichalek132 opened this issue Dec 9, 2023 · 0 comments · Fixed by #11499
Labels
type/feature Something new we should do

Comments

@jmichalek132
Copy link
Contributor

Is your feature request related to a problem? Please describe.
For greater visibility into the source of a query, add the ability in Loki to log the value of an arbitrary set of request headers in the query frontend stats log.

For example, if a Loki operator wanted to log the originating IP address of the sender after being sent the data through a proxy, adding the header X-Forwarded-For could be added to this configuration to log the IP address to the query stats log.

Describe the solution you'd like
Implementing similiar functionality as grafana/mimir#5030 in loki. Specifically for this log line https://github.com/jmichalek132/loki/blob/main/pkg/logql/metrics.go#L120.

Describe alternatives you've considered
There is support for logging key values present in a header X-Query-Tags. But that would require proxy populating those headers. Instead I think it would make sense to support something that is already supported in Mimir.

Additional context
Linking original issue for implementing the same in mimir grafana/mimir#4815.
If maintainer are willing to accept this change I am willing to implement it.

@JStickler JStickler added the type/feature Something new we should do label Dec 11, 2023
dannykopping pushed a commit that referenced this issue Jan 22, 2024
…1499)

**What this PR does / why we need it**:

Adding feature present in mimir, specifically
grafana/mimir#5030.

Adds a config option to the query-frontend to specify a list of request
headers to include in query logs.

For example, setting
-frontend.log-query-request-headers="X-Grafana-Org-Id" and sending a
query with X-Grafana-Org-Id:1 results in query log lines that include
header_x_grafana_org_id=1.

**Which issue(s) this PR fixes**:
Fixes #11422
rhnasc pushed a commit to inloco/loki that referenced this issue Apr 12, 2024
…afana#11499)

**What this PR does / why we need it**:

Adding feature present in mimir, specifically
grafana/mimir#5030.

Adds a config option to the query-frontend to specify a list of request
headers to include in query logs.

For example, setting
-frontend.log-query-request-headers="X-Grafana-Org-Id" and sending a
query with X-Grafana-Org-Id:1 results in query log lines that include
header_x_grafana_org_id=1.

**Which issue(s) this PR fixes**:
Fixes grafana#11422
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type/feature Something new we should do
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants