Skip to content

Commit 35cbe38

Browse files
committed
Make Alert Manager API Concurrency configurable
Signed-off-by: Emmanuel Lodovice <lodovice@amazon.com>
1 parent a307fc0 commit 35cbe38

File tree

4 files changed

+11
-1
lines changed

4 files changed

+11
-1
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
* [FEATURE] Query Frontend: Add `cortex_rejected_queries_total` metric for throttled queries. #5356
1717
* [FEATURE] Querier: Log query stats when querying store gateway. #5376
1818
* [FEATURE] Querier/StoreGateway: Allow the tenant shard sizes to be a percent of total instances. #5393
19+
* [FEATURE] Added the flag `-alertmanager.api-concurrency` to configure alert manager api concurrency limit. #5412
1920
* [ENHANCEMENT] Distributor/Ingester: Add span on push path #5319
2021
* [ENHANCEMENT] Support object storage backends for runtime configuration file. #5292
2122
* [ENHANCEMENT] Query Frontend: Reject subquery with too small step size. #5323

docs/configuration/config-file-reference.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -416,6 +416,10 @@ cluster:
416416
# CLI flag: -experimental.alertmanager.enable-api
417417
[enable_api: <boolean> | default = false]
418418
419+
# Maximum number of concurrent GET API requests before returning 503.
420+
# CLI flag: -alertmanager.api-concurrency
421+
[api_concurrency: <int> | default = 0]
422+
419423
alertmanager_client:
420424
# Timeout for downstream alertmanagers.
421425
# CLI flag: -alertmanager.alertmanager-client.remote-timeout

pkg/alertmanager/alertmanager.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -80,6 +80,7 @@ type Config struct {
8080
Replicator Replicator
8181
Store alertstore.AlertStore
8282
PersisterConfig PersisterConfig
83+
APIConcurrency int
8384
}
8485

8586
// An Alertmanager manages the alerts for one user.
@@ -266,6 +267,7 @@ func New(cfg *Config, reg *prometheus.Registry) (*Alertmanager, error) {
266267
GroupFunc: func(f1 func(*dispatch.Route) bool, f2 func(*types.Alert, time.Time) bool) (dispatch.AlertGroups, map[model.Fingerprint][]string) {
267268
return am.dispatcher.Groups(f1, f2)
268269
},
270+
Concurrency: am.cfg.APIConcurrency,
269271
})
270272
if err != nil {
271273
return nil, fmt.Errorf("failed to create api: %v", err)

pkg/alertmanager/multitenant.go

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,8 @@ type MultitenantAlertmanagerConfig struct {
7878

7979
Cluster ClusterConfig `yaml:"cluster"`
8080

81-
EnableAPI bool `yaml:"enable_api"`
81+
EnableAPI bool `yaml:"enable_api"`
82+
APIConcurrency int `yaml:"api_concurrency"`
8283

8384
// For distributor.
8485
AlertmanagerClient ClientConfig `yaml:"alertmanager_client"`
@@ -117,6 +118,7 @@ func (cfg *MultitenantAlertmanagerConfig) RegisterFlags(f *flag.FlagSet) {
117118
f.DurationVar(&cfg.PollInterval, "alertmanager.configs.poll-interval", 15*time.Second, "How frequently to poll Cortex configs")
118119

119120
f.BoolVar(&cfg.EnableAPI, "experimental.alertmanager.enable-api", false, "Enable the experimental alertmanager config api.")
121+
f.IntVar(&cfg.APIConcurrency, "alertmanager.api-concurrency", 0, "Maximum number of concurrent GET API requests before returning 503.")
120122

121123
f.BoolVar(&cfg.ShardingEnabled, "alertmanager.sharding-enabled", false, "Shard tenants across multiple alertmanager instances.")
122124
f.Var(&cfg.EnabledTenants, "alertmanager.enabled-tenants", "Comma separated list of tenants whose alerts this alertmanager can process. If specified, only these tenants will be handled by alertmanager, otherwise this alertmanager can process alerts from all tenants.")
@@ -965,6 +967,7 @@ func (am *MultitenantAlertmanager) newAlertmanager(userID string, amConfig *amco
965967
Store: am.store,
966968
PersisterConfig: am.cfg.Persister,
967969
Limits: am.limits,
970+
APIConcurrency: am.cfg.APIConcurrency,
968971
}, reg)
969972
if err != nil {
970973
return nil, fmt.Errorf("unable to start Alertmanager for user %v: %v", userID, err)

0 commit comments

Comments
 (0)