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

Prometheus: Restore FromAlert header #55255

Merged
merged 3 commits into from Sep 22, 2022
Merged

Prometheus: Restore FromAlert header #55255

merged 3 commits into from Sep 22, 2022

Conversation

kylebrandt
Copy link
Contributor

@kylebrandt kylebrandt commented Sep 15, 2022

What this PR does / why we need it:
Restores the FromAlert header to prometheus that comes for Grafana Managed Alert queries.

Which issue(s) this PR fixes:

Fixes #54403

Special notes for your reviewer:
I think was made a feature by accident, but people are using Load balance / route queries to different higher SLA servers for alerting.

So this doesn't fix that it isn't thought out as feature (e.g. document, support across datasource, less fragile internal code then a header). But it does provide a fix of restoring the header.

This reverts #51518 , but with the change to only pass through the FromAlert header.

@grafanabot
Copy link
Contributor

@kylebrandt kylebrandt added this to the 9.1.6 milestone Sep 19, 2022
@grafanabot
Copy link
Contributor

@kylebrandt kylebrandt added the backport v9.1.x Bot will automatically open backport PR label Sep 19, 2022
@kylebrandt kylebrandt marked this pull request as ready for review September 19, 2022 12:08
@kylebrandt kylebrandt requested a review from a team as a code owner September 19, 2022 12:08
@kylebrandt kylebrandt changed the title Restore from alert prom Prometheus: Restore FromAlert header Sep 19, 2022
@kylebrandt
Copy link
Contributor Author

@aocenas Are you able to check this out since it reverts a PR of yours?

@xlson xlson modified the milestones: 9.1.6, 9.1.7 Sep 20, 2022
addHeaders := make(map[string]string)

if req.Headers["FromAlert"] == "true" {
addHeaders["FromAlert"] = "true"
Copy link
Member

Choose a reason for hiding this comment

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

Is this only for the FromAlert info? Out of curiosity why is it needed to send to prometheus? Could it be moved to infra code so that it is always sent downstream?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Only for the header. Since it was being sent, people have used it to load balance on. So they point their datasource at their LB and use the header to route differently.

Not sure I follow with moving to the infra code? This doesn't seem like the right way to fix it to me, but trying to undo the experienced regression for the user.

Copy link
Member

Choose a reason for hiding this comment

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

Yep got it, this works so no issue in merging.

Not sure I follow with moving to the infra code?

We are already handling headers in grafana backend in general by providing a HTTP client to datasource, so it does not have to be handled custom, which is why this code was removed. We may somehow move this to the HTTP client that is provided so that FromAlert header would be passed upstream for all datasources automatically if it is valuable in general.

@kylebrandt kylebrandt merged commit 2728827 into main Sep 22, 2022
@kylebrandt kylebrandt deleted the restoreFromAlertProm branch September 22, 2022 15:03
grafanabot pushed a commit that referenced this pull request Sep 22, 2022
This restores the FromAlert header to prometheus for Grafana managed alert Queries.

It does this by reverting "Prometheus: Remove middleware for custom headers (#51518)" , but also changing it so it is only the FromAlert header.

This reverts commit 2372501.

(cherry picked from commit 2728827)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Missing Fromalert and X-Cache-Skip HTTP headers since v9.1.0
4 participants