From fbc209df43d7872aec2a4898fbf5998d444fb3d2 Mon Sep 17 00:00:00 2001
From: Marco Pracucci <marco@pracucci.com>
Date: Mon, 17 May 2021 12:42:38 +0200
Subject: [PATCH] Changed alertmanager config to use the new storage config

Signed-off-by: Marco Pracucci <marco@pracucci.com>
---
 CHANGELOG.md            |  1 +
 cortex/config.libsonnet | 24 +++++++++---------------
 2 files changed, 10 insertions(+), 15 deletions(-)

diff --git a/CHANGELOG.md b/CHANGELOG.md
index 95380929..071c8b21 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -8,6 +8,7 @@
 * [CHANGE] Replaced the deprecated CLI flag `-limits.per-user-override-config` (removed in Cortex 1.9) with `-runtime-config.file`. #304
 * [CHANGE] Ruler: changed ruler config to use the new storage config. #306
 * [CHANGE] Ruler: enabled API response compression. #306
+* [CHANGE] Alertmanager: changed alertmanager config to use the new storage config. #307
 * [FEATURE] Added "Cortex / Rollout progress" dashboard. #289 #290
 * [FEATURE] Added support for using query-scheduler component, which moves the queue out of query-frontend, and allows scaling up of query-frontend component. #295
 * [ENHANCEMENT] Added `newCompactorStatefulSet()` function to create a custom statefulset for the compactor. #287
diff --git a/cortex/config.libsonnet b/cortex/config.libsonnet
index 21913b75..b53b54ab 100644
--- a/cortex/config.libsonnet
+++ b/cortex/config.libsonnet
@@ -253,9 +253,8 @@
     },
 
     ruler_enabled: false,
-    ruler_client_type: error 'you must specify a storage backend type for the ruler (azure, configdb, gcs, s3, local)',
-    // TODO: Generic client generating functions would be nice.
-    ruler_s3_bucket_name: $._config.s3_bucket_name,
+    ruler_client_type: error 'you must specify a storage backend type for the ruler (azure, gcs, s3, local)',
+    ruler_s3_bucket_name: error 'you must specify the ruler S3 bucket name',
     ruler_gcs_bucket_name: error 'must specify a GCS bucket name',
 
     rulerClientConfig:
@@ -263,9 +262,6 @@
         'ruler-storage.backend': $._config.ruler_client_type,
       } +
       {
-        configdb: {
-          configs_api_url: 'config.%s.svc.cluster.local' % $._config.namespace,
-        },
         gcs: {
           'ruler-storage.gcs.bucket-name': $._config.ruler_gcs_bucket_name,
         },
@@ -284,26 +280,24 @@
       fallback_config: {},
     },
 
-    alertmanager_client_type: error 'you must specify a storage backend type for the alertmanager (azure, configdb, gcs, s3, local)',
-    alertmanager_s3_bucket_name: $._config.s3_bucket_name,
+    alertmanager_client_type: error 'you must specify a storage backend type for the alertmanager (azure, gcs, s3, local)',
+    alertmanager_s3_bucket_name: error 'you must specify the alertmanager S3 bucket name',
     alertmanager_gcs_bucket_name: error 'must specify a GCS bucket name',
 
     alertmanagerStorageClientConfig:
       {
-        'alertmanager.storage.type': $._config.alertmanager_client_type,
+        'alertmanager-storage.backend': $._config.alertmanager_client_type,
       } +
       {
-        configdb: {
-          configs_api_url: 'config.%s.svc.cluster.local' % $._config.namespace,
-        },
         gcs: {
-          'alertmanager.storage.gcs.bucketname': $._config.alertmanager_gcs_bucket_name,
+          'alertmanager-storage.gcs.bucket-name': $._config.alertmanager_gcs_bucket_name,
         },
         s3: {
-          'alertmanager.storage.s3.url': 'https://%s/%s' % [$._config.aws_region, $._config.alertmanager_s3_bucket_name],
+          'alertmanager-storage.s3.region': $._config.aws_region,
+          'alertmanager-storage.s3.bucket-name': $._config.alertmanager_s3_bucket_name,
         },
         'local': {
-          'alertmanager.storage.local.directory': $._config.alertmanager_local_directory,
+          'alertmanager-storage.local.path': $._config.alertmanager_local_directory,
         },
       }[$._config.alertmanager_client_type],