-
Notifications
You must be signed in to change notification settings - Fork 545
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
Alertmanager: Add grafana config size limit #9402
Conversation
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.
Looking good, couple of nits.
pkg/alertmanager/api_grafana.go
Outdated
if err != nil { | ||
maxBytesErr := &http.MaxBytesError{} |
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.
No need for this to be a pointer (but see comment below, I don't think we need to keep it)
maxBytesErr := &http.MaxBytesError{} | |
var maxBytesErr http.MaxBytesError |
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.
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.
Wow, TIL. That's.... odd.
var input io.Reader | ||
maxConfigSize := am.limits.AlertmanagerMaxGrafanaConfigSize(userID) | ||
if maxConfigSize > 0 { | ||
input = http.MaxBytesReader(w, r.Body, int64(maxConfigSize)) |
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.
Is there any practical difference between this and io.LimitReader
which we use in api.go?
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.
I saw the io.LimitReader
example but I found that a bit confusing TBH - i.e. the reader returns an EOF (with nil
error), so we have to explicitly check for the size. http.MaxReader
will return an error of type MaxBytesError
- IMO this has a better readability.
But I can switch to the LimitReader for consistency if that's preferred 👍
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.
I'm happy as-is, maybe we switch the LimitReader usage over in a follow up.
@@ -3666,6 +3666,11 @@ The `limits` block configures default and per-tenant limits imposed by component | |||
# CLI flag: -alertmanager.notification-rate-limit-per-integration | |||
[alertmanager_notification_rate_limit_per_integration: <map of string to float64> | default = {}] | |||
|
|||
# Maximum size of the grafana configuration file for Alertmanager that tenant |
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.
# Maximum size of the grafana configuration file for Alertmanager that tenant | |
# Maximum size of the Grafana configuration file for Alertmanager that a tenant |
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.
Done
@@ -3666,6 +3666,11 @@ The `limits` block configures default and per-tenant limits imposed by component | |||
# CLI flag: -alertmanager.notification-rate-limit-per-integration | |||
[alertmanager_notification_rate_limit_per_integration: <map of string to float64> | default = {}] | |||
|
|||
# Maximum size of the grafana configuration file for Alertmanager that tenant | |||
# can upload via Alertmanager API. 0 = no limit. |
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.
# can upload via Alertmanager API. 0 = no limit. | |
# can upload via the Alertmanager API. 0 = no limit. |
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.
Done 👍
CHANGELOG.md
Outdated
@@ -3236,6 +3236,8 @@ _Changes since `grafana/cortex-jsonnet` `1.9.0`._ | |||
} | |||
``` | |||
* [FEATURE] Added multi-zone ingesters and store-gateways support. #1352 #1552 | |||
* [FEATURE] The following alertmanager limit was added: #9402 |
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.
This needs to go at the top of the file (and not in the jsonnet section)
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.
lol... Tks, done now 👍
9841950
to
acf749e
Compare
The CHANGELOG has just been cut to prepare for the next release. Please rebase |
acf749e
to
9d9e501
Compare
53c259a
to
ee1d491
Compare
Awesome, tks! Done now 👍 |
Co-authored-by: Oleg Zaytsev <[email protected]>
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.
LGTM, just a changelog nit.
Co-authored-by: Steve Simpson <[email protected]>
Remote AM already has limits in place for it's own configuration. However, when using grafana compat mode, it doesn't have any. This aims to add a new config limit for grafana configuration.