From b1f99705811d3fc798519c56af17771c96d2f642 Mon Sep 17 00:00:00 2001 From: Song Gao <2695690803@qq.com> Date: Thu, 2 Apr 2020 12:08:07 +0800 Subject: [PATCH] fix alertmanager --- pkg/monitor/monitor/template.go | 9 +-------- pkg/monitor/monitor/template_test.go | 6 ++++++ 2 files changed, 7 insertions(+), 8 deletions(-) diff --git a/pkg/monitor/monitor/template.go b/pkg/monitor/monitor/template.go index f7d4ee6efd6..ab8f70fdb3c 100644 --- a/pkg/monitor/monitor/template.go +++ b/pkg/monitor/monitor/template.go @@ -103,11 +103,6 @@ type MonitorConfigModel struct { func newPrometheusConfig(cmodel *MonitorConfigModel) *config.Config { var c = config.Config{ - AlertingConfig: config.AlertingConfig{ - AlertRelabelConfigs: nil, - AlertmanagerConfigs: nil, - XXX: nil, - }, GlobalConfig: config.GlobalConfig{ ScrapeInterval: model.Duration(15 * time.Second), EvaluationInterval: model.Duration(15 * time.Second), @@ -249,9 +244,7 @@ func addAlertManagerUrl(pc *config.Config, cmodel *MonitorConfigModel) { StaticConfigs: []*config.TargetGroup{ { Targets: []model.LabelSet{ - map[model.LabelName]model.LabelValue{ - "targets": model.LabelValue(cmodel.AlertmanagerURL), - }, + {model.AddressLabel: model.LabelValue(cmodel.AlertmanagerURL)}, }, }, }, diff --git a/pkg/monitor/monitor/template_test.go b/pkg/monitor/monitor/template_test.go index 4c4825487ca..4d886a646d8 100644 --- a/pkg/monitor/monitor/template_test.go +++ b/pkg/monitor/monitor/template_test.go @@ -25,6 +25,11 @@ func TestRenderPrometheusConfig(t *testing.T) { expectedContent := `global: scrape_interval: 15s evaluation_interval: 15s +alerting: + alertmanagers: + - static_configs: + - targets: + - alert-url rule_files: - /prometheus-rules/rules/*.rules.yml scrape_configs: @@ -180,6 +185,7 @@ scrape_configs: "ns2", }, EnableTLSCluster: false, + AlertmanagerURL: "alert-url", } content, err := RenderPrometheusConfig(model) g.Expect(err).NotTo(HaveOccurred())