-
Notifications
You must be signed in to change notification settings - Fork 3.5k
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
Promtail: Add custom headers on push requests (#7470) #7472
Conversation
./tools/diff_coverage.sh ../loki-main/test_results.txt test_results.txt ingester,distributor,querier,querier/queryrange,iter,storage,chunkenc,logql,loki Change in test coverage per package. Green indicates 0 or positive change, red indicates that test coverage for a package fell. + ingester 0%
+ distributor 0%
+ querier 0%
- querier/queryrange -0.1%
+ iter 0%
+ storage 0%
+ chunkenc 0%
+ logql 0%
+ loki 0% |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hey @Jack-Kingdom thanks for your PR. I proposed some minor changes.
What will happen to custom_header if it has X-Scope-OrgID header, tenant1 or tenant2? // UnmarshalYAML implement Yaml Unmarshaler
func (c *Config) UnmarshalYAML(unmarshal func(interface{}) error) error {
...
if err := unmarshal(&cfg); err != nil {
return err
}
//Validate config
if c.TenantID!=""&&len(c.CustomHeaders)>0 {
_,ok:=c.CustomHeaders["X-Scope-OrgID"]
if ok {
return errors.New("illegal promtail header X-Scope-OrgID")
}
}
*c = Config(cfg)
return nil
} |
In the current implementation |
./tools/diff_coverage.sh ../loki-main/test_results.txt test_results.txt ingester,distributor,querier,querier/queryrange,iter,storage,chunkenc,logql,loki Change in test coverage per package. Green indicates 0 or positive change, red indicates that test coverage for a package fell. - ingester -0.1%
+ distributor 0%
+ querier 0%
+ querier/queryrange 0%
+ iter 0%
+ storage 0%
+ chunkenc 0%
+ logql 0%
+ loki 0% |
IMO it's inelegant to check config race condition. I update those logical, so that makt it won't override existing headers. // Add custom headers on request
if len(c.cfg.CustomHeaders) > 0 {
for k, v := range c.cfg.CustomHeaders {
if req.Header.Get(k) == "" {
req.Header.Add(k, v)
}else {
level.Warn(c.logger).Log("msg", "custom header key already exists, skipping", "key", k)
}
}
} |
./tools/diff_coverage.sh ../loki-main/test_results.txt test_results.txt ingester,distributor,querier,querier/queryrange,iter,storage,chunkenc,logql,loki Change in test coverage per package. Green indicates 0 or positive change, red indicates that test coverage for a package fell. + ingester 0%
+ distributor 0%
+ querier 0%
+ querier/queryrange 0%
+ iter 0%
+ storage 0%
+ chunkenc 0%
+ logql 0%
+ loki 0% |
What do you think, if we replace custom_headers with headers, custom_headers is too long for me and it's easy for me to make mistakes. https://prometheus.io/docs/prometheus/latest/configuration/configuration/#remote_write
|
In addition, this header feature is great, we have some gateway systems for security, need to have some authentication header. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@Jack-Kingdom Thanks for this contribution. This is looking good. There is an open question on renaming this to headers
. This would make it consistent with Loki. Can you have a look at that?
@Jack-Kingdom Do you want to address the remaining issue (renaming to |
./tools/diff_coverage.sh ../loki-main/test_results.txt test_results.txt ingester,distributor,querier,querier/queryrange,iter,storage,chunkenc,logql,loki Change in test coverage per package. Green indicates 0 or positive change, red indicates that test coverage for a package fell. + ingester 0%
+ distributor 0%
+ querier 0%
+ querier/queryrange 0%
+ iter 0%
+ storage 0%
+ chunkenc 0%
+ logql 0%
+ loki 0% |
./tools/diff_coverage.sh ../loki-main/test_results.txt test_results.txt ingester,distributor,querier,querier/queryrange,iter,storage,chunkenc,logql,loki Change in test coverage per package. Green indicates 0 or positive change, red indicates that test coverage for a package fell. + ingester 0%
+ distributor 0%
+ querier 0%
+ querier/queryrange 0%
+ iter 0%
+ storage 0%
+ chunkenc 0%
+ logql 0%
+ loki 0% |
1 similar comment
./tools/diff_coverage.sh ../loki-main/test_results.txt test_results.txt ingester,distributor,querier,querier/queryrange,iter,storage,chunkenc,logql,loki Change in test coverage per package. Green indicates 0 or positive change, red indicates that test coverage for a package fell. + ingester 0%
+ distributor 0%
+ querier 0%
+ querier/queryrange 0%
+ iter 0%
+ storage 0%
+ chunkenc 0%
+ logql 0%
+ loki 0% |
@chaudum Hi,I have rename custom_header to header in client config. Please hava a review of this commit. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for changes. I have two small wording suggestions for documentation.
@chaudum I made some changes to those codes and combine them into a single commit. Please take a review. |
@Jack-Kingdom could you merge main and see that the build gets green. I can merge it then 😊 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[Docs squad] LGTM
Hi, Is this already released? |
This wasn't added to v2.7.4 because it is a new feature instead of a fix/patch. |
What this PR does / why we need it:
add custom headers support on promtail send reqeust
Which issue(s) this PR fixes:
Fixes #7470
Checklist
CONTRIBUTING.md
guideCHANGELOG.md
updateddocs/sources/upgrading/_index.md