Skip to content

Commit

Permalink
Merge pull request #1256 from arajkumar/alertmanager-loglevel
Browse files Browse the repository at this point in the history
Allow configuration of the log level for Alertmanager in the CMO configmap
  • Loading branch information
openshift-merge-robot committed Jun 30, 2021
2 parents f2a0824 + 37e1071 commit fb0e576
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 0 deletions.
1 change: 1 addition & 0 deletions pkg/manifests/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -128,6 +128,7 @@ type TLSConfig struct {
}

type AlertmanagerMainConfig struct {
LogLevel string `json:"logLevel"`
NodeSelector map[string]string `json:"nodeSelector"`
Tolerations []v1.Toleration `json:"tolerations"`
Resources *v1.ResourceRequirements `json:"resources"`
Expand Down
4 changes: 4 additions & 0 deletions pkg/manifests/manifests.go
Original file line number Diff line number Diff line change
Expand Up @@ -412,6 +412,10 @@ func (f *Factory) AlertmanagerMain(host string, trustedCABundleCM *v1.ConfigMap)

a.Spec.ExternalURL = f.AlertmanagerExternalURL(host).String()

if f.config.ClusterMonitoringConfiguration.AlertmanagerMainConfig.LogLevel != "" {
a.Spec.LogLevel = f.config.ClusterMonitoringConfiguration.AlertmanagerMainConfig.LogLevel
}

if f.config.ClusterMonitoringConfiguration.AlertmanagerMainConfig.Resources != nil {
a.Spec.Resources = *f.config.ClusterMonitoringConfiguration.AlertmanagerMainConfig.Resources
}
Expand Down
5 changes: 5 additions & 0 deletions pkg/manifests/manifests_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -1210,6 +1210,7 @@ k8sPrometheusAdapter:

func TestAlertmanagerMainConfiguration(t *testing.T) {
c, err := NewConfigFromString(`alertmanagerMain:
logLevel: debug
baseImage: quay.io/test/alertmanager
nodeSelector:
type: worker
Expand Down Expand Up @@ -1247,6 +1248,10 @@ ingress:
t.Fatal(err)
}

if a.Spec.LogLevel != "debug" {
t.Fatalf("Alertmanager logLevel is not configured correctly, want: 'debug', got: '%s'", a.Spec.LogLevel)
}

if *a.Spec.Image != "docker.io/openshift/origin-prometheus-alertmanager:latest" {
t.Fatal("Alertmanager image is not configured correctly")
}
Expand Down

0 comments on commit fb0e576

Please sign in to comment.