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

Allow specifying custom headers for Loki log output #3227

Merged
merged 3 commits into from Jul 27, 2023

Conversation

federicotdn
Copy link
Contributor

@federicotdn federicotdn commented Jul 25, 2023

What?

Allows users to specify custom headers for the loki log output option. For example:

--log-output=loki=http://example.org,header.X-My-Header=123,header.Authorization=mytoken

In this case, requests done to example.org will contain the HTTP headers X-My-Header: 123 and Authorization: mytoken.

Why?

See issue #3216 and backlinked issue from the Grafana private repository.

Checklist

  • I have performed a self-review of my code.
  • I have added tests for my changes.
  • I have run linter locally (make ci-like-lint) and all checks pass.
  • I have run tests locally (make tests) and all tests pass.
  • I have commented on my code, particularly in hard-to-understand areas.

Related PR(s)/Issue(s)

#3216
#3224 (this PR implements the other half of #3216)

@codecov-commenter
Copy link

Codecov Report

Merging #3227 (ba783fd) into master (59d9f9b) will decrease coverage by 0.09%.
The diff coverage is 94.73%.

❗ Current head ba783fd differs from pull request most recent head 2ceea68. Consider uploading reports for the commit 2ceea68 to get more accurate results

@@            Coverage Diff             @@
##           master    #3227      +/-   ##
==========================================
- Coverage   73.18%   73.10%   -0.09%     
==========================================
  Files         259      257       -2     
  Lines       19864    19890      +26     
==========================================
+ Hits        14538    14541       +3     
- Misses       4404     4420      +16     
- Partials      922      929       +7     
Flag Coverage Δ
ubuntu 73.10% <94.73%> (-0.03%) ⬇️
windows ?

Flags with carried forward coverage won't be shown. Click here to find out more.

Files Changed Coverage Δ
log/loki.go 68.70% <80.00%> (+0.21%) ⬆️
output/cloud/expv2/flush.go 93.47% <94.73%> (+2.43%) ⬆️
output/cloud/expv2/output.go 74.23% <100.00%> (+1.39%) ⬆️

... and 12 files with indirect coverage changes

@mstoykov mstoykov requested review from oleiade and removed request for olegbespalov July 25, 2023 13:55
mstoykov
mstoykov previously approved these changes Jul 25, 2023
Copy link
Collaborator

@mstoykov mstoykov left a comment

Choose a reason for hiding this comment

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

Thanks for the PR 🙇

LGTM in general, but some comments!

I have a single requested change.

But I also would prefer if we can get a small test that actually checks this.

The last test in loki_test.go starts a test server already so you can copy it and check the correct headers are send.

log/loki.go Outdated Show resolved Hide resolved
@mstoykov mstoykov added this to the v0.46.0 milestone Jul 26, 2023
@mstoykov mstoykov merged commit 3c006a5 into master Jul 27, 2023
21 checks passed
@mstoykov mstoykov deleted the feat/3216-add-headers-loki-out branch July 27, 2023 13:37
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.

None yet

4 participants