Skip to content

Commit 8c62379

Browse files
committed
Enable compactor and alertmanager in target all
Signed-off-by: SungJin1212 <[email protected]>
1 parent d0f253c commit 8c62379

File tree

3 files changed

+24
-6
lines changed

3 files changed

+24
-6
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
## master / unreleased
44

5+
* [CHANGE] Enable Compactor and Alertmanager in target all. #6204
56
* [FEATURE] Ruler: Experimental: Add `ruler.frontend-address` to allow query to query frontends instead of ingesters. #6151
67
* [FEATURE] Ruler: Minimize chances of missed rule group evaluations that can occur due to OOM kills, bad underlying nodes, or due to an unhealthy ruler that appears in the ring as healthy. This feature is enabled via `-ruler.enable-ha-evaluation` flag. #6129
78
* [ENHANCEMENT] Query Frontend: Add peakSample in query stats response. #6188

pkg/cortex/cortex_test.go

Lines changed: 20 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12,10 +12,12 @@ import (
1212
"testing"
1313
"time"
1414

15+
"github.com/cortexproject/cortex/pkg/alertmanager"
16+
"github.com/cortexproject/cortex/pkg/alertmanager/alertstore"
1517
"github.com/cortexproject/cortex/pkg/cortex/storage"
1618
"github.com/cortexproject/cortex/pkg/ruler/rulestore"
1719
"github.com/cortexproject/cortex/pkg/ruler/rulestore/local"
18-
20+
"github.com/cortexproject/cortex/pkg/util/flagext"
1921
"github.com/prometheus/client_golang/prometheus"
2022
"github.com/stretchr/testify/assert"
2123
"github.com/stretchr/testify/require"
@@ -92,10 +94,23 @@ func TestCortex(t *testing.T) {
9294
Directory: os.TempDir(),
9395
},
9496
},
95-
96-
Target: []string{All, Compactor},
97+
AlertmanagerStorage: alertstore.Config{
98+
Config: bucket.Config{
99+
Backend: "local",
100+
},
101+
},
102+
Target: []string{All},
97103
}
98104

105+
externalURL := flagext.URLValue{}
106+
err := externalURL.Set("http://localhost/api/prom")
107+
require.NoError(t, err)
108+
109+
multiAlertmanagerCfg := &alertmanager.MultitenantAlertmanagerConfig{}
110+
flagext.DefaultValues(multiAlertmanagerCfg)
111+
multiAlertmanagerCfg.ExternalURL = externalURL
112+
cfg.Alertmanager = *multiAlertmanagerCfg
113+
99114
c, err := New(cfg)
100115
require.NoError(t, err)
101116

@@ -114,8 +129,9 @@ func TestCortex(t *testing.T) {
114129
require.NotNil(t, serviceMap[Ring])
115130
require.NotNil(t, serviceMap[DistributorService])
116131

117-
// check that compactor is configured which is not part of Target=All
132+
// check compactor and alertmanager are configured.
118133
require.NotNil(t, serviceMap[Compactor])
134+
require.NotNil(t, serviceMap[AlertManager])
119135
}
120136

121137
func TestConfigValidation(t *testing.T) {

pkg/cortex/modules.go

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -646,7 +646,8 @@ func (t *Cortex) initAlertManager() (serv services.Service, err error) {
646646
return
647647
}
648648

649-
t.API.RegisterAlertmanager(t.Alertmanager, t.Cfg.isModuleEnabled(AlertManager), t.Cfg.Alertmanager.EnableAPI)
649+
apiEnabled := t.Cfg.isModuleEnabled(AlertManager) || t.Cfg.isModuleEnabled(All)
650+
t.API.RegisterAlertmanager(t.Alertmanager, apiEnabled, t.Cfg.Alertmanager.EnableAPI)
650651
return t.Alertmanager, nil
651652
}
652653

@@ -788,7 +789,7 @@ func (t *Cortex) setupModuleManager() error {
788789
TenantDeletion: {API, Overrides},
789790
Purger: {TenantDeletion},
790791
TenantFederation: {Queryable},
791-
All: {QueryFrontend, Querier, Ingester, Distributor, Purger, StoreGateway, Ruler},
792+
All: {QueryFrontend, Querier, Ingester, Distributor, Purger, StoreGateway, Ruler, Compactor, AlertManager},
792793
}
793794
if t.Cfg.ExternalPusher != nil && t.Cfg.ExternalQueryable != nil {
794795
deps[Ruler] = []string{Overrides, RulerStorage}

0 commit comments

Comments
 (0)