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

Alerting: Align notifier truncation and logging with prometheus/alertmanager #59339

Merged
merged 6 commits into from
Dec 14, 2022

Conversation

alexweav
Copy link
Contributor

Some external systems have limits on message sizes. Prometheus handles this in a unified way. We recently touched this area in upstream.

The way we do truncation and log is very inconsistent in Grafana notifiers, even among each other.

Why do we need this feature?

This PR aligns Grafana's notifier field truncation with upstream. We now use the same logic in the same places, same constants, and emit the same logs.

Effectively, ports prometheus/alertmanager#3135 and prometheus/alertmanager#3145 to Grafana, plus some additional alignment that was missing entirely.

Who is this feature for?

Contributes to alignment of alertmanagers.

Which issue(s) does this PR fix?:

Contributes to https://github.com/grafana/alerting-squad/issues/304
Contributes to https://github.com/grafana/alerting-squad/issues/240

Special notes for your reviewer:

@alexweav alexweav added area/alerting Grafana Alerting area/alerting/notifications Issues when sending alert notifications area/backend type/debt technical debt no-backport Skip backport of PR no-changelog Skip including change in changelog/release notes labels Nov 25, 2022
@alexweav alexweav added this to the 9.4.0 milestone Nov 25, 2022
@alexweav alexweav requested a review from a team as a code owner November 25, 2022 21:26
Comment on lines +340 to +343
// TruncateInBytes truncates a string to fit the given size in Bytes.
// TODO: This is more advanced than the upstream's TruncateInBytes. We should consider upstreaming this, and removing it from here.
Copy link
Contributor Author

@alexweav alexweav Nov 25, 2022

Choose a reason for hiding this comment

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

Copied verbatim from webex.go. I added the TODO so we remember to do this in the future.
Prometheus's equivalent of this is also in util.go so I felt this was the place of best alignment.

Comment on lines +231 to +235
message = strings.TrimSpace(message)
if message == "" {
// Pushover rejects empty messages.
message = "(no details)"
}
Copy link
Contributor Author

Choose a reason for hiding this comment

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

taken from Prometheus

@alexweav
Copy link
Contributor Author

lint error resolved in #59432

Copy link
Contributor

@yuri-tceretian yuri-tceretian left a comment

Choose a reason for hiding this comment

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

LGTM

@alexweav
Copy link
Contributor Author

Upstream PR is now merged, this is unblocked. Few minor changes to uptake.

@alexweav alexweav merged commit 821614f into main Dec 14, 2022
@alexweav alexweav deleted the alexweav/align-truncation branch December 14, 2022 01:50
@dsotirakis dsotirakis modified the milestones: 9.4.0, 9.4.0-beta1 Jan 30, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area/alerting/notifications Issues when sending alert notifications area/alerting Grafana Alerting area/backend enterprise-ok no-backport Skip backport of PR no-changelog Skip including change in changelog/release notes type/debt technical debt
Projects
Archived in project
Development

Successfully merging this pull request may close these issues.

None yet

4 participants