2015-01-21 11:07:45 -08:00
|
|
|
// Copyright 2013 The Prometheus Authors
|
2013-08-09 10:32:55 -07:00
|
|
|
// Licensed under the Apache License, Version 2.0 (the "License");
|
|
|
|
// you may not use this file except in compliance with the License.
|
|
|
|
// You may obtain a copy of the License at
|
|
|
|
//
|
|
|
|
// http://www.apache.org/licenses/LICENSE-2.0
|
|
|
|
//
|
|
|
|
// Unless required by applicable law or agreed to in writing, software
|
|
|
|
// distributed under the License is distributed on an "AS IS" BASIS,
|
|
|
|
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
|
|
// See the License for the specific language governing permissions and
|
|
|
|
// limitations under the License.
|
|
|
|
|
2016-03-01 03:37:22 -08:00
|
|
|
package notifier
|
2013-08-09 10:32:55 -07:00
|
|
|
|
|
|
|
import (
|
2015-12-10 07:31:50 -08:00
|
|
|
"encoding/json"
|
|
|
|
"fmt"
|
2017-02-27 11:31:16 -08:00
|
|
|
"io/ioutil"
|
2013-08-09 10:32:55 -07:00
|
|
|
"net/http"
|
2015-12-10 07:31:50 -08:00
|
|
|
"net/http/httptest"
|
2017-04-24 22:42:33 -07:00
|
|
|
"net/url"
|
2015-12-10 07:31:50 -08:00
|
|
|
"reflect"
|
2013-08-09 10:32:55 -07:00
|
|
|
"testing"
|
|
|
|
"time"
|
|
|
|
|
2017-02-27 11:31:16 -08:00
|
|
|
"golang.org/x/net/context"
|
|
|
|
|
2015-08-20 08:18:46 -07:00
|
|
|
"github.com/prometheus/common/model"
|
2016-08-09 01:08:15 -07:00
|
|
|
"github.com/prometheus/prometheus/config"
|
2016-12-29 07:53:11 -08:00
|
|
|
"github.com/prometheus/prometheus/pkg/labels"
|
2013-08-09 10:32:55 -07:00
|
|
|
)
|
|
|
|
|
2016-11-23 08:03:22 -08:00
|
|
|
func TestPostPath(t *testing.T) {
|
2016-02-04 02:56:14 -08:00
|
|
|
var cases = []struct {
|
|
|
|
in, out string
|
|
|
|
}{
|
|
|
|
{
|
2016-11-23 08:03:22 -08:00
|
|
|
in: "",
|
|
|
|
out: "/api/v1/alerts",
|
2016-02-04 02:56:14 -08:00
|
|
|
},
|
|
|
|
{
|
2016-11-23 08:03:22 -08:00
|
|
|
in: "/",
|
|
|
|
out: "/api/v1/alerts",
|
2016-02-04 02:56:14 -08:00
|
|
|
},
|
|
|
|
{
|
2016-11-23 08:03:22 -08:00
|
|
|
in: "/prefix",
|
|
|
|
out: "/prefix/api/v1/alerts",
|
2016-02-04 02:56:14 -08:00
|
|
|
},
|
|
|
|
{
|
2016-11-23 08:03:22 -08:00
|
|
|
in: "/prefix//",
|
|
|
|
out: "/prefix/api/v1/alerts",
|
2016-02-04 02:56:14 -08:00
|
|
|
},
|
|
|
|
{
|
2016-11-23 08:03:22 -08:00
|
|
|
in: "prefix//",
|
|
|
|
out: "/prefix/api/v1/alerts",
|
2016-02-04 02:56:14 -08:00
|
|
|
},
|
|
|
|
}
|
|
|
|
for _, c := range cases {
|
2016-11-23 08:03:22 -08:00
|
|
|
if res := postPath(c.in); res != c.out {
|
|
|
|
t.Errorf("Expected post path %q for %q but got %q", c.out, c.in, res)
|
2016-02-04 02:56:14 -08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2015-12-10 07:31:50 -08:00
|
|
|
func TestHandlerNextBatch(t *testing.T) {
|
2016-03-01 03:37:22 -08:00
|
|
|
h := New(&Options{})
|
2015-12-10 07:31:50 -08:00
|
|
|
|
|
|
|
for i := range make([]struct{}, 2*maxBatchSize+1) {
|
2016-12-29 07:53:11 -08:00
|
|
|
h.queue = append(h.queue, &Alert{
|
|
|
|
Labels: labels.FromStrings("alertname", fmt.Sprintf("%d", i)),
|
2015-12-10 07:31:50 -08:00
|
|
|
})
|
|
|
|
}
|
|
|
|
|
2016-12-29 07:53:11 -08:00
|
|
|
expected := append([]*Alert{}, h.queue...)
|
2015-12-10 07:31:50 -08:00
|
|
|
|
|
|
|
b := h.nextBatch()
|
|
|
|
|
|
|
|
if len(b) != maxBatchSize {
|
|
|
|
t.Fatalf("Expected first batch of length %d, but got %d", maxBatchSize, len(b))
|
|
|
|
}
|
2016-12-29 07:53:11 -08:00
|
|
|
if !alertsEqual(expected[0:maxBatchSize], b) {
|
2015-12-10 07:31:50 -08:00
|
|
|
t.Fatalf("First batch did not match")
|
|
|
|
}
|
|
|
|
|
|
|
|
b = h.nextBatch()
|
|
|
|
|
|
|
|
if len(b) != maxBatchSize {
|
|
|
|
t.Fatalf("Expected second batch of length %d, but got %d", maxBatchSize, len(b))
|
|
|
|
}
|
2016-12-29 07:53:11 -08:00
|
|
|
if !alertsEqual(expected[maxBatchSize:2*maxBatchSize], b) {
|
2015-12-10 07:31:50 -08:00
|
|
|
t.Fatalf("Second batch did not match")
|
|
|
|
}
|
2013-08-09 10:32:55 -07:00
|
|
|
|
2015-12-10 07:31:50 -08:00
|
|
|
b = h.nextBatch()
|
|
|
|
|
|
|
|
if len(b) != 1 {
|
|
|
|
t.Fatalf("Expected third batch of length %d, but got %d", 1, len(b))
|
|
|
|
}
|
2016-12-29 07:53:11 -08:00
|
|
|
if !alertsEqual(expected[2*maxBatchSize:], b) {
|
2015-12-10 07:31:50 -08:00
|
|
|
t.Fatalf("Third batch did not match")
|
|
|
|
}
|
|
|
|
|
|
|
|
if len(h.queue) != 0 {
|
|
|
|
t.Fatalf("Expected queue to be empty but got %d alerts", len(h.queue))
|
|
|
|
}
|
2013-08-09 10:32:55 -07:00
|
|
|
}
|
|
|
|
|
2016-12-29 07:53:11 -08:00
|
|
|
func alertsEqual(a, b []*Alert) bool {
|
2015-12-10 07:31:50 -08:00
|
|
|
if len(a) != len(b) {
|
2016-12-29 07:53:11 -08:00
|
|
|
fmt.Println("len mismatch")
|
2015-12-10 07:31:50 -08:00
|
|
|
return false
|
|
|
|
}
|
|
|
|
for i, alert := range a {
|
2016-12-29 07:53:11 -08:00
|
|
|
if !labels.Equal(alert.Labels, b[i].Labels) {
|
|
|
|
fmt.Println("mismatch", alert.Labels, b[i].Labels)
|
2015-12-10 07:31:50 -08:00
|
|
|
return false
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return true
|
2013-08-09 10:32:55 -07:00
|
|
|
}
|
|
|
|
|
2016-06-02 05:25:19 -07:00
|
|
|
func TestHandlerSendAll(t *testing.T) {
|
2015-12-10 07:31:50 -08:00
|
|
|
var (
|
2016-12-29 07:53:11 -08:00
|
|
|
expected []*Alert
|
2016-06-02 05:25:19 -07:00
|
|
|
status1, status2 int
|
2015-12-10 07:31:50 -08:00
|
|
|
)
|
2013-08-09 10:32:55 -07:00
|
|
|
|
2016-06-02 05:25:19 -07:00
|
|
|
f := func(w http.ResponseWriter, r *http.Request) {
|
2015-12-10 07:31:50 -08:00
|
|
|
defer r.Body.Close()
|
2013-08-09 10:32:55 -07:00
|
|
|
|
2016-12-29 07:53:11 -08:00
|
|
|
var alerts []*Alert
|
2015-12-10 07:31:50 -08:00
|
|
|
if err := json.NewDecoder(r.Body).Decode(&alerts); err != nil {
|
|
|
|
t.Fatalf("Unexpected error on input decoding: %s", err)
|
|
|
|
}
|
|
|
|
|
|
|
|
if !alertsEqual(alerts, expected) {
|
|
|
|
t.Errorf("%#v %#v", *alerts[0], *expected[0])
|
|
|
|
t.Fatalf("Unexpected alerts received %v exp %v", alerts, expected)
|
|
|
|
}
|
2016-06-02 05:25:19 -07:00
|
|
|
}
|
|
|
|
server1 := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
|
|
|
|
f(w, r)
|
|
|
|
w.WriteHeader(status1)
|
|
|
|
}))
|
|
|
|
server2 := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
|
|
|
|
f(w, r)
|
|
|
|
w.WriteHeader(status2)
|
2015-12-10 07:31:50 -08:00
|
|
|
}))
|
|
|
|
|
2016-06-02 05:25:19 -07:00
|
|
|
defer server1.Close()
|
|
|
|
defer server2.Close()
|
2015-12-10 07:31:50 -08:00
|
|
|
|
2016-11-23 08:03:22 -08:00
|
|
|
h := New(&Options{})
|
|
|
|
h.alertmanagers = append(h.alertmanagers, &alertmanagerSet{
|
|
|
|
ams: []alertmanager{
|
2016-11-25 02:11:28 -08:00
|
|
|
alertmanagerMock{
|
|
|
|
urlf: func() string { return server1.URL },
|
|
|
|
},
|
|
|
|
alertmanagerMock{
|
|
|
|
urlf: func() string { return server2.URL },
|
|
|
|
},
|
2016-11-23 08:03:22 -08:00
|
|
|
},
|
2016-11-24 06:17:50 -08:00
|
|
|
cfg: &config.AlertmanagerConfig{
|
2016-11-23 08:03:22 -08:00
|
|
|
Timeout: time.Second,
|
|
|
|
},
|
2015-12-10 07:31:50 -08:00
|
|
|
})
|
2013-08-09 10:32:55 -07:00
|
|
|
|
2015-12-10 07:31:50 -08:00
|
|
|
for i := range make([]struct{}, maxBatchSize) {
|
2016-12-29 07:53:11 -08:00
|
|
|
h.queue = append(h.queue, &Alert{
|
|
|
|
Labels: labels.FromStrings("alertname", fmt.Sprintf("%d", i)),
|
2015-12-10 07:31:50 -08:00
|
|
|
})
|
2016-12-29 07:53:11 -08:00
|
|
|
expected = append(expected, &Alert{
|
|
|
|
Labels: labels.FromStrings("alertname", fmt.Sprintf("%d", i)),
|
2015-12-10 07:31:50 -08:00
|
|
|
})
|
|
|
|
}
|
|
|
|
|
2016-06-02 05:25:19 -07:00
|
|
|
status1 = http.StatusOK
|
|
|
|
status2 = http.StatusOK
|
2016-11-23 08:03:22 -08:00
|
|
|
if !h.sendAll(h.queue...) {
|
|
|
|
t.Fatalf("all sends failed unexpectedly")
|
2015-12-10 07:31:50 -08:00
|
|
|
}
|
|
|
|
|
2016-06-02 05:25:19 -07:00
|
|
|
status1 = http.StatusNotFound
|
2016-11-23 08:03:22 -08:00
|
|
|
if !h.sendAll(h.queue...) {
|
|
|
|
t.Fatalf("all sends failed unexpectedly")
|
2016-06-02 05:25:19 -07:00
|
|
|
}
|
2013-08-09 10:32:55 -07:00
|
|
|
|
2016-06-02 05:25:19 -07:00
|
|
|
status2 = http.StatusInternalServerError
|
2016-11-23 08:03:22 -08:00
|
|
|
if h.sendAll(h.queue...) {
|
|
|
|
t.Fatalf("all sends succeeded unexpectedly")
|
2013-08-09 10:32:55 -07:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2017-02-27 11:31:16 -08:00
|
|
|
func TestCustomDo(t *testing.T) {
|
|
|
|
const testURL = "http://testurl.com/"
|
|
|
|
const testBody = "testbody"
|
|
|
|
|
|
|
|
var received bool
|
|
|
|
h := New(&Options{
|
|
|
|
Do: func(ctx context.Context, client *http.Client, req *http.Request) (*http.Response, error) {
|
|
|
|
received = true
|
|
|
|
body, err := ioutil.ReadAll(req.Body)
|
|
|
|
if err != nil {
|
|
|
|
t.Fatalf("Unable to read request body: %v", err)
|
|
|
|
}
|
|
|
|
if string(body) != testBody {
|
|
|
|
t.Fatalf("Unexpected body; want %v, got %v", testBody, string(body))
|
|
|
|
}
|
|
|
|
if req.URL.String() != testURL {
|
|
|
|
t.Fatalf("Unexpected URL; want %v, got %v", testURL, req.URL.String())
|
|
|
|
}
|
|
|
|
return &http.Response{
|
|
|
|
Body: ioutil.NopCloser(nil),
|
|
|
|
}, nil
|
|
|
|
},
|
|
|
|
})
|
|
|
|
|
|
|
|
h.sendOne(context.Background(), nil, testURL, []byte(testBody))
|
|
|
|
|
|
|
|
if !received {
|
|
|
|
t.Fatal("Expected to receive an alert, but didn't")
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2016-09-27 05:34:56 -07:00
|
|
|
func TestExternalLabels(t *testing.T) {
|
|
|
|
h := New(&Options{
|
|
|
|
QueueCapacity: 3 * maxBatchSize,
|
|
|
|
ExternalLabels: model.LabelSet{"a": "b"},
|
|
|
|
RelabelConfigs: []*config.RelabelConfig{
|
|
|
|
{
|
|
|
|
SourceLabels: model.LabelNames{"alertname"},
|
|
|
|
TargetLabel: "a",
|
|
|
|
Action: "replace",
|
|
|
|
Regex: config.MustNewRegexp("externalrelabelthis"),
|
|
|
|
Replacement: "c",
|
|
|
|
},
|
|
|
|
},
|
|
|
|
})
|
|
|
|
|
|
|
|
// This alert should get the external label attached.
|
2016-12-29 07:53:11 -08:00
|
|
|
h.Send(&Alert{
|
|
|
|
Labels: labels.FromStrings("alertname", "test"),
|
2016-09-27 05:34:56 -07:00
|
|
|
})
|
|
|
|
|
|
|
|
// This alert should get the external label attached, but then set to "c"
|
|
|
|
// through relabelling.
|
2016-12-29 07:53:11 -08:00
|
|
|
h.Send(&Alert{
|
|
|
|
Labels: labels.FromStrings("alertname", "externalrelabelthis"),
|
2016-09-27 05:34:56 -07:00
|
|
|
})
|
|
|
|
|
2016-12-29 07:53:11 -08:00
|
|
|
expected := []*Alert{
|
|
|
|
{Labels: labels.FromStrings("alertname", "test", "a", "b")},
|
|
|
|
{Labels: labels.FromStrings("alertname", "externalrelabelthis", "a", "c")},
|
2016-09-27 05:34:56 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
if !alertsEqual(expected, h.queue) {
|
|
|
|
t.Errorf("Expected alerts %v, got %v", expected, h.queue)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2016-08-09 01:08:15 -07:00
|
|
|
func TestHandlerRelabel(t *testing.T) {
|
|
|
|
h := New(&Options{
|
|
|
|
QueueCapacity: 3 * maxBatchSize,
|
|
|
|
RelabelConfigs: []*config.RelabelConfig{
|
2016-09-14 20:13:27 -07:00
|
|
|
{
|
2016-08-09 01:08:15 -07:00
|
|
|
SourceLabels: model.LabelNames{"alertname"},
|
|
|
|
Action: "drop",
|
|
|
|
Regex: config.MustNewRegexp("drop"),
|
|
|
|
},
|
2016-09-14 20:13:27 -07:00
|
|
|
{
|
2016-08-09 01:08:15 -07:00
|
|
|
SourceLabels: model.LabelNames{"alertname"},
|
|
|
|
TargetLabel: "alertname",
|
|
|
|
Action: "replace",
|
|
|
|
Regex: config.MustNewRegexp("rename"),
|
|
|
|
Replacement: "renamed",
|
|
|
|
},
|
|
|
|
},
|
|
|
|
})
|
|
|
|
|
|
|
|
// This alert should be dropped due to the configuration
|
2016-12-29 07:53:11 -08:00
|
|
|
h.Send(&Alert{
|
|
|
|
Labels: labels.FromStrings("alertname", "drop"),
|
2016-08-09 01:08:15 -07:00
|
|
|
})
|
|
|
|
|
|
|
|
// This alert should be replaced due to the configuration
|
2016-12-29 07:53:11 -08:00
|
|
|
h.Send(&Alert{
|
|
|
|
Labels: labels.FromStrings("alertname", "rename"),
|
2016-08-09 01:08:15 -07:00
|
|
|
})
|
|
|
|
|
2016-12-29 07:53:11 -08:00
|
|
|
expected := []*Alert{
|
|
|
|
{Labels: labels.FromStrings("alertname", "renamed")},
|
2016-08-09 01:08:15 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
if !alertsEqual(expected, h.queue) {
|
|
|
|
t.Errorf("Expected alerts %v, got %v", expected, h.queue)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
func TestHandlerQueueing(t *testing.T) {
|
2015-12-10 07:31:50 -08:00
|
|
|
var (
|
|
|
|
unblock = make(chan struct{})
|
|
|
|
called = make(chan struct{})
|
2016-12-29 07:53:11 -08:00
|
|
|
expected []*Alert
|
2015-12-10 07:31:50 -08:00
|
|
|
)
|
|
|
|
|
|
|
|
server := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
|
|
|
|
called <- struct{}{}
|
|
|
|
<-unblock
|
|
|
|
|
|
|
|
defer r.Body.Close()
|
|
|
|
|
2016-12-29 07:53:11 -08:00
|
|
|
var alerts []*Alert
|
2015-12-10 07:31:50 -08:00
|
|
|
if err := json.NewDecoder(r.Body).Decode(&alerts); err != nil {
|
|
|
|
t.Fatalf("Unexpected error on input decoding: %s", err)
|
|
|
|
}
|
|
|
|
|
|
|
|
if !alertsEqual(expected, alerts) {
|
|
|
|
t.Errorf("Expected alerts %v, got %v", expected, alerts)
|
|
|
|
}
|
|
|
|
}))
|
|
|
|
|
2016-03-01 03:37:22 -08:00
|
|
|
h := New(&Options{
|
2016-11-23 08:03:22 -08:00
|
|
|
QueueCapacity: 3 * maxBatchSize,
|
|
|
|
})
|
|
|
|
h.alertmanagers = append(h.alertmanagers, &alertmanagerSet{
|
|
|
|
ams: []alertmanager{
|
2016-11-25 02:11:28 -08:00
|
|
|
alertmanagerMock{
|
|
|
|
urlf: func() string { return server.URL },
|
|
|
|
},
|
2016-11-23 08:03:22 -08:00
|
|
|
},
|
2016-11-24 06:17:50 -08:00
|
|
|
cfg: &config.AlertmanagerConfig{
|
2016-11-23 08:03:22 -08:00
|
|
|
Timeout: time.Second,
|
|
|
|
},
|
2015-12-10 07:31:50 -08:00
|
|
|
})
|
|
|
|
|
2016-12-29 07:53:11 -08:00
|
|
|
var alerts []*Alert
|
|
|
|
|
2015-12-10 07:31:50 -08:00
|
|
|
for i := range make([]struct{}, 20*maxBatchSize) {
|
2016-12-29 07:53:11 -08:00
|
|
|
alerts = append(alerts, &Alert{
|
|
|
|
Labels: labels.FromStrings("alertname", fmt.Sprintf("%d", i)),
|
2015-12-10 07:31:50 -08:00
|
|
|
})
|
|
|
|
}
|
|
|
|
|
|
|
|
go h.Run()
|
|
|
|
defer h.Stop()
|
|
|
|
|
|
|
|
h.Send(alerts[:4*maxBatchSize]...)
|
|
|
|
|
|
|
|
// If the batch is larger than the queue size, the front should be truncated
|
|
|
|
// from the front. Thus, we start at i=1.
|
|
|
|
for i := 1; i < 4; i++ {
|
|
|
|
select {
|
|
|
|
case <-called:
|
|
|
|
expected = alerts[i*maxBatchSize : (i+1)*maxBatchSize]
|
|
|
|
unblock <- struct{}{}
|
2016-01-25 09:31:54 -08:00
|
|
|
case <-time.After(5 * time.Second):
|
2015-12-10 07:31:50 -08:00
|
|
|
t.Fatalf("Alerts were not pushed")
|
|
|
|
}
|
2013-08-09 10:32:55 -07:00
|
|
|
}
|
|
|
|
|
2015-12-10 07:31:50 -08:00
|
|
|
// Send one batch, wait for it to arrive and block so the queue fills up.
|
|
|
|
// Then check whether the queue is truncated in the front once its full.
|
|
|
|
h.Send(alerts[:maxBatchSize]...)
|
|
|
|
<-called
|
|
|
|
|
|
|
|
// Fill the 3*maxBatchSize queue.
|
|
|
|
h.Send(alerts[1*maxBatchSize : 2*maxBatchSize]...)
|
|
|
|
h.Send(alerts[2*maxBatchSize : 3*maxBatchSize]...)
|
|
|
|
h.Send(alerts[3*maxBatchSize : 4*maxBatchSize]...)
|
|
|
|
|
|
|
|
// Send the batch that drops the first one.
|
|
|
|
h.Send(alerts[4*maxBatchSize : 5*maxBatchSize]...)
|
|
|
|
|
|
|
|
expected = alerts[:maxBatchSize]
|
|
|
|
unblock <- struct{}{}
|
|
|
|
|
|
|
|
for i := 2; i < 4; i++ {
|
|
|
|
select {
|
|
|
|
case <-called:
|
|
|
|
expected = alerts[i*maxBatchSize : (i+1)*maxBatchSize]
|
|
|
|
unblock <- struct{}{}
|
2016-01-25 09:31:54 -08:00
|
|
|
case <-time.After(5 * time.Second):
|
2015-12-10 07:31:50 -08:00
|
|
|
t.Fatalf("Alerts were not pushed")
|
|
|
|
}
|
2013-08-09 10:32:55 -07:00
|
|
|
}
|
|
|
|
}
|
2016-11-25 02:11:28 -08:00
|
|
|
|
|
|
|
type alertmanagerMock struct {
|
|
|
|
urlf func() string
|
|
|
|
}
|
|
|
|
|
2017-04-24 22:42:33 -07:00
|
|
|
func (a alertmanagerMock) url() *url.URL {
|
|
|
|
u, err := url.Parse(a.urlf())
|
|
|
|
if err != nil {
|
|
|
|
panic(err)
|
|
|
|
}
|
|
|
|
return u
|
2016-11-25 02:11:28 -08:00
|
|
|
}
|
2017-05-17 07:24:22 -07:00
|
|
|
|
|
|
|
func TestLabelSetNotReused(t *testing.T) {
|
|
|
|
tg := makeInputTargetGroup()
|
|
|
|
_, err := alertmanagerFromGroup(tg, &config.AlertmanagerConfig{})
|
|
|
|
if err != nil {
|
|
|
|
t.Fatal(err)
|
|
|
|
}
|
|
|
|
|
|
|
|
if !reflect.DeepEqual(tg, makeInputTargetGroup()) {
|
|
|
|
t.Fatal("Target modified during alertmanager extraction")
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
func makeInputTargetGroup() *config.TargetGroup {
|
|
|
|
return &config.TargetGroup{
|
|
|
|
Targets: []model.LabelSet{
|
|
|
|
model.LabelSet{
|
|
|
|
model.AddressLabel: model.LabelValue("1.1.1.1:9090"),
|
|
|
|
model.LabelName("notcommon1"): model.LabelValue("label"),
|
|
|
|
},
|
|
|
|
},
|
|
|
|
Labels: model.LabelSet{
|
|
|
|
model.LabelName("common"): model.LabelValue("label"),
|
|
|
|
},
|
|
|
|
Source: "testsource",
|
|
|
|
}
|
|
|
|
}
|