-
Notifications
You must be signed in to change notification settings - Fork 812
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
Added limit for size of configuration file that tenant can upload to Alertmanager. #4201
Added limit for size of configuration file that tenant can upload to Alertmanager. #4201
Conversation
…Alertmanager. Signed-off-by: Peter Štibraný <[email protected]>
Signed-off-by: Peter Štibraný <[email protected]>
Signed-off-by: Peter Štibraný <[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 👏 great work.
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.
Good job! LGTM (modulo a couple of nits I would be glad if you could take a look at)
pkg/util/validation/limits.go
Outdated
@@ -173,6 +174,7 @@ func (l *Limits) RegisterFlags(f *flag.FlagSet) { | |||
l.NotificationRateLimitPerIntegration = NotificationRateLimitMap{} | |||
} | |||
f.Var(&l.NotificationRateLimitPerIntegration, "alertmanager.notification-rate-limit-per-integration", "Per-integration notification rate limits. Value is a map, where each key is integration name and value is a rate-limit (float). On command line, this map is given in JSON format. Rate limit has the same meaning as -alertmanager.notification-rate-limit, but only applies for specific integration. Allowed integration names: "+strings.Join(allowedIntegrationNames, ", ")+".") | |||
f.IntVar(&l.AlertmanagerMaxConfigSize, "alertmanager.max-config-size", 0, "Maximum size of 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.
[nit] I'm wondering if, to make it even more clear, we should mention it's in bytes. We can do it in the CLI flag description but I'm also wondering if we should add a -bytes
suffix to the config like we have for other configs.
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.
Sounds good. I will update it.
pkg/alertmanager/api.go
Outdated
if err != nil { | ||
level.Error(logger).Log("msg", errReadingConfiguration, "err", err.Error()) | ||
http.Error(w, fmt.Sprintf("%s: %s", errReadingConfiguration, err.Error()), http.StatusBadRequest) | ||
return | ||
} | ||
|
||
if maxConfigSize > 0 && len(payload) > maxConfigSize { | ||
msg := fmt.Sprintf(errConfigurationTooBig, maxConfigSize) | ||
level.Error(logger).Log("msg", msg) |
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 is not an actionable error on Cortex side, so I wouldn't use the error level. I would use Warn instead.
Signed-off-by: Peter Štibraný <[email protected]>
What this PR does: This PR introduces new limit in Alertmanager: limit for size of configuration file that tenant can upload.
Checklist
CHANGELOG.md
updated - the order of entries should be[CHANGE]
,[FEATURE]
,[ENHANCEMENT]
,[BUGFIX]