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

Added limit for size of configuration file that tenant can upload to Alertmanager. #4201

Merged
merged 5 commits into from
May 25, 2021

Conversation

pstibrany
Copy link
Contributor

@pstibrany pstibrany commented May 19, 2021

What this PR does: This PR introduces new limit in Alertmanager: limit for size of configuration file that tenant can upload.

Checklist

  • Tests updated
  • Documentation added
  • CHANGELOG.md updated - the order of entries should be [CHANGE], [FEATURE], [ENHANCEMENT], [BUGFIX]

pstibrany added 2 commits May 19, 2021 17:21
Signed-off-by: Peter Štibraný <[email protected]>
Signed-off-by: Peter Štibraný <[email protected]>
Copy link
Contributor

@gotjosh gotjosh left a comment

Choose a reason for hiding this comment

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

LGTM 👏 great work.

Copy link
Contributor

@pracucci pracucci left a 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)

@@ -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.")
Copy link
Contributor

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.

Copy link
Contributor Author

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.

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)
Copy link
Contributor

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.

@pstibrany pstibrany merged commit 89a0232 into cortexproject:master May 25, 2021
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.

3 participants