@@ -18,6 +18,8 @@ import (
18
18
"context"
19
19
"fmt"
20
20
"os"
21
+ "strconv"
22
+ "strings"
21
23
"testing"
22
24
23
25
gokitlog "github.com/go-kit/log"
@@ -27,6 +29,7 @@ import (
27
29
"github.com/prometheus/prometheus/discovery"
28
30
"github.com/prometheus/prometheus/discovery/targetgroup"
29
31
"github.com/prometheus/prometheus/model/relabel"
32
+ "github.com/stretchr/testify/require"
30
33
ctrl "sigs.k8s.io/controller-runtime"
31
34
"sigs.k8s.io/controller-runtime/pkg/log"
32
35
@@ -66,10 +69,21 @@ func BenchmarkProcessTargetsWithRelabelConfig(b *testing.B) {
66
69
tsets := prepareBenchmarkData (numTargets , targetsPerGroup , groupsPerJob )
67
70
prehookConfig := make (map [string ][]* relabel.Config , len (tsets ))
68
71
for jobName := range tsets {
72
+ // keep all targets in half the jobs, drop the rest
73
+ jobNrStr := strings .Split (jobName , "-" )[1 ]
74
+ jobNr , err := strconv .Atoi (jobNrStr )
75
+ require .NoError (b , err )
76
+ var action relabel.Action
77
+ if jobNr % 2 == 0 {
78
+ action = "keep"
79
+ } else {
80
+ action = "drop"
81
+ }
69
82
prehookConfig [jobName ] = []* relabel.Config {
70
83
{
71
- Action : "keep" ,
72
- Regex : relabel .MustNewRegexp (".*" ),
84
+ Action : action ,
85
+ Regex : relabel .MustNewRegexp (".*" ),
86
+ SourceLabels : model.LabelNames {"__address__" },
73
87
},
74
88
}
75
89
}
0 commit comments