Skip to content

feat: Alertmanger support for azure blob storage #3634

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

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
* [ENHANCEMENT] Memberlist: add status page (/memberlist) with available details about memberlist-based KV store and memberlist cluster. It's also possible to view KV values in Go struct or JSON format, or download for inspection. #3575
* [ENHANCEMENT] Memberlist: client can now keep a size-bounded buffer with sent and received messages and display them in the admin UI (/memberlist) for troubleshooting. #3581 #3602
* [ENHANCEMENT] Blocks storage: added block index attributes caching support to metadata cache. The TTL can be configured via `-blocks-storage.bucket-store.metadata-cache.block-index-attributes-ttl`. #3629
* [ENHANCEMENT] Alertmanager: Add support for Azure blob storage. #3634
* [BUGFIX] Allow `-querier.max-query-lookback` use `y|w|d` suffix like deprecated `-store.max-look-back-period`. #3598
* [BUGFIX] Memberlist: Entry in the ring should now not appear again after using "Forget" feature (unless it's still heartbeating). #3603

Expand Down
55 changes: 51 additions & 4 deletions docs/configuration/config-file-reference.md
Original file line number Diff line number Diff line change
Expand Up @@ -1522,10 +1522,52 @@ storage:
# The CLI flags prefix for this block config is: alertmanager
[configdb: <configstore_config>]

local:
# Path at which alertmanager configurations are stored.
# CLI flag: -alertmanager.storage.local.path
[path: <string> | default = ""]
azure:
# Azure Cloud environment. Supported values are: AzureGlobal,
# AzureChinaCloud, AzureGermanCloud, AzureUSGovernment.
# CLI flag: -alertmanager.storage.azure.environment
[environment: <string> | default = "AzureGlobal"]

# Name of the blob container used to store chunks. This container must be
# created before running cortex.
# CLI flag: -alertmanager.storage.azure.container-name
[container_name: <string> | default = "cortex"]

# The Microsoft Azure account name to be used
# CLI flag: -alertmanager.storage.azure.account-name
[account_name: <string> | default = ""]

# The Microsoft Azure account key to use.
# CLI flag: -alertmanager.storage.azure.account-key
[account_key: <string> | default = ""]

# Preallocated buffer size for downloads.
# CLI flag: -alertmanager.storage.azure.download-buffer-size
[download_buffer_size: <int> | default = 512000]

# Preallocated buffer size for uploads.
# CLI flag: -alertmanager.storage.azure.upload-buffer-size
[upload_buffer_size: <int> | default = 256000]

# Number of buffers used to used to upload a chunk.
# CLI flag: -alertmanager.storage.azure.download-buffer-count
[upload_buffer_count: <int> | default = 1]

# Timeout for requests made against azure blob storage.
# CLI flag: -alertmanager.storage.azure.request-timeout
[request_timeout: <duration> | default = 30s]

# Number of retries for a request which times out.
# CLI flag: -alertmanager.storage.azure.max-retries
[max_retries: <int> | default = 5]

# Minimum time to wait before retrying a request.
# CLI flag: -alertmanager.storage.azure.min-retry-delay
[min_retry_delay: <duration> | default = 10ms]

# Maximum time to wait before retrying a request.
# CLI flag: -alertmanager.storage.azure.max-retry-delay
[max_retry_delay: <duration> | default = 500ms]

gcs:
# Name of GCS bucket. Please refer to
Expand Down Expand Up @@ -1602,6 +1644,11 @@ storage:
# CLI flag: -alertmanager.storage.s3.signature-version
[signature_version: <string> | default = "v4"]

local:
# Path at which alertmanager configurations are stored.
# CLI flag: -alertmanager.storage.local.path
[path: <string> | default = ""]

# Enable the experimental alertmanager config api.
# CLI flag: -experimental.alertmanager.enable-api
[enable_api: <boolean> | default = false]
Expand Down
25 changes: 17 additions & 8 deletions pkg/alertmanager/storage.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ import (
"github.com/cortexproject/cortex/pkg/alertmanager/alerts/objectclient"
"github.com/cortexproject/cortex/pkg/chunk"
"github.com/cortexproject/cortex/pkg/chunk/aws"
"github.com/cortexproject/cortex/pkg/chunk/azure"
"github.com/cortexproject/cortex/pkg/chunk/gcp"
"github.com/cortexproject/cortex/pkg/configs/client"
)
Expand All @@ -27,26 +28,32 @@ type AlertStore interface {

// AlertStoreConfig configures the alertmanager backend
type AlertStoreConfig struct {
Type string `yaml:"type"`
ConfigDB client.Config `yaml:"configdb"`
Local local.StoreConfig `yaml:"local"`
Type string `yaml:"type"`
ConfigDB client.Config `yaml:"configdb"`

GCS gcp.GCSConfig `yaml:"gcs"`
S3 aws.S3Config `yaml:"s3"`
// Object Storage Configs
Azure azure.BlobStorageConfig `yaml:"azure"`
GCS gcp.GCSConfig `yaml:"gcs"`
S3 aws.S3Config `yaml:"s3"`
Local local.StoreConfig `yaml:"local"`
}

// RegisterFlags registers flags.
func (cfg *AlertStoreConfig) RegisterFlags(f *flag.FlagSet) {
cfg.Local.RegisterFlags(f)
cfg.ConfigDB.RegisterFlagsWithPrefix("alertmanager.", f)
f.StringVar(&cfg.Type, "alertmanager.storage.type", "configdb", "Type of backend to use to store alertmanager configs. Supported values are: \"configdb\", \"gcs\", \"s3\", \"local\".")

cfg.Azure.RegisterFlagsWithPrefix("alertmanager.storage.", f)
cfg.GCS.RegisterFlagsWithPrefix("alertmanager.storage.", f)
cfg.S3.RegisterFlagsWithPrefix("alertmanager.storage.", f)
cfg.Local.RegisterFlags(f)
}

// Validate config and returns error on failure
func (cfg *AlertStoreConfig) Validate() error {
if err := cfg.Azure.Validate(); err != nil {
return errors.Wrap(err, "invalid Azure Storage config")
}
if err := cfg.S3.Validate(); err != nil {
return errors.Wrap(err, "invalid S3 Storage config")
}
Expand All @@ -62,12 +69,14 @@ func NewAlertStore(cfg AlertStoreConfig) (AlertStore, error) {
return nil, err
}
return configdb.NewStore(c), nil
case "local":
return local.NewStore(cfg.Local)
case "azure":
return newObjAlertStore(azure.NewBlobStorage(&cfg.Azure))
case "gcs":
return newObjAlertStore(gcp.NewGCSObjectClient(context.Background(), cfg.GCS))
case "s3":
return newObjAlertStore(aws.NewS3ObjectClient(cfg.S3))
case "local":
return local.NewStore(cfg.Local)
default:
return nil, fmt.Errorf("unrecognized alertmanager storage backend %v, choose one of: azure, configdb, gcs, local, s3", cfg.Type)
}
Expand Down