Skip to content

ruler: allow configuring custom HTTP headers for query and Alertmanager endpoints - #9056

Merged
saswatamcode merged 2 commits into
thanos-io:mainfrom
Rohilalala:rule-query-http-headers
Oct 2, 2026
Merged

saswatamcode merged 2 commits into
thanos-io:mainfrom
Rohilalala:rule-query-http-headers

Conversation

@Rohilalala

Copy link
Copy Markdown
Contributor

Fixes #9052

Right now the Ruler can't send custom headers (like a tenant ID) when it queries, so you end up running a proxy just to add them. This adds an http_headers option to the HTTP client config. It works the same way as http_headers in Prometheus, so you can use values, secrets or files.

Since it's on the shared client config, it also works for Alertmanager, Sidecar and Receive. Headers like Authorization are still rejected at startup, same as in Prometheus.

I added tests in pkg/clientconfig that check the headers actually reach a test server (including one read from a file) and that Authorization gets rejected. Also added a small example to the Ruler docs and a CHANGELOG entry.

  • I added CHANGELOG entry for this change.
  • Change is not relevant to the end user.

This PR was written in part with the assistance of generative AI; I reviewed and tested the changes.

â€Ķer endpoints

Signed-off-by: Aditya <205600203+Rohilalala@users.noreply.github.com>
@codecov

codecov Bot commented Sep 30, 2026 •

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 64.63%. Comparing base (a7c9f1e) to head (ad323a3).

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #9056      +/-   ##
==========================================
+ Coverage   64.56%   64.63%   +0.06%     
==========================================
  Files         289      289              
  Lines       37420    37423       +3     
==========================================
+ Hits        24162    24190      +28     
+ Misses      11158    11143      -15     
+ Partials     2100     2090      -10     

☔ View full report in Codecov by Harness.
ðŸ“Ē Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄ïļ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • ðŸ“Ķ JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

saswatamcode
saswatamcode previously approved these changes Oct 1, 2026

@saswatamcode saswatamcode left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

LGTM!

Comment thread docs/components/rule.md
endpoint_addresses: []
```

To send extra headers with every HTTP query, for example a tenant ID, set `http_headers` in `http_config`. Each header takes `values`, `secrets` or `files`, as in Prometheus' `http_headers`; relative `files` paths are resolved from the working directory. The Alertmanager `http_config` accepts it too:

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Maybe just a comment, I'd probably not recommend running a ruler per tenant (unless you have limited number of tenants)

â€Ķounts

Signed-off-by: Aditya <205600203+Rohilalala@users.noreply.github.com>
@saswatamcode
saswatamcode merged commit e11582d into thanos-io:main Oct 2, 2026
26 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Allow setting HTTP Headers in Ruler QueryConfig

2 participants