|
|
|
@ -1020,6 +1020,51 @@ func TestScrapeLoopSeriesAdded(t *testing.T) {
|
|
|
|
|
require.Equal(t, 0, seriesAdded)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
func TestScrapeLoopFailWithInvalidLabelsAfterRelabel(t *testing.T) {
|
|
|
|
|
s := teststorage.New(t)
|
|
|
|
|
defer s.Close()
|
|
|
|
|
ctx, cancel := context.WithCancel(context.Background())
|
|
|
|
|
defer cancel()
|
|
|
|
|
|
|
|
|
|
target := &Target{
|
|
|
|
|
labels: labels.FromStrings("pod_label_invalid_012", "test"),
|
|
|
|
|
}
|
|
|
|
|
relabelConfig := []*relabel.Config{{
|
|
|
|
|
Action: relabel.LabelMap,
|
|
|
|
|
Regex: relabel.MustNewRegexp("pod_label_invalid_(.+)"),
|
|
|
|
|
Separator: ";",
|
|
|
|
|
Replacement: "$1",
|
|
|
|
|
}}
|
|
|
|
|
sl := newScrapeLoop(ctx,
|
|
|
|
|
&testScraper{},
|
|
|
|
|
nil, nil,
|
|
|
|
|
func(l labels.Labels) labels.Labels {
|
|
|
|
|
return mutateSampleLabels(l, target, true, relabelConfig)
|
|
|
|
|
},
|
|
|
|
|
nopMutator,
|
|
|
|
|
s.Appender,
|
|
|
|
|
nil,
|
|
|
|
|
0,
|
|
|
|
|
true,
|
|
|
|
|
0,
|
|
|
|
|
nil,
|
|
|
|
|
0,
|
|
|
|
|
0,
|
|
|
|
|
false,
|
|
|
|
|
false,
|
|
|
|
|
nil,
|
|
|
|
|
false,
|
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
slApp := sl.appender(ctx)
|
|
|
|
|
total, added, seriesAdded, err := sl.append(slApp, []byte("test_metric 1\n"), "", time.Time{})
|
|
|
|
|
require.ErrorContains(t, err, "invalid metric name or label names")
|
|
|
|
|
require.NoError(t, slApp.Rollback())
|
|
|
|
|
require.Equal(t, 1, total)
|
|
|
|
|
require.Equal(t, 0, added)
|
|
|
|
|
require.Equal(t, 0, seriesAdded)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
func makeTestMetrics(n int) []byte {
|
|
|
|
|
// Construct a metrics string to parse
|
|
|
|
|
sb := bytes.Buffer{}
|
|
|
|
|