@@ -120,8 +120,44 @@ func (s *Server) UpdateScrapeConfigResponse(configs map[string]*promconfig.Scrap
120
120
if err != nil {
121
121
return err
122
122
}
123
+
124
+ var jobToScrapeConfig map [string ]interface {}
125
+ err = json .Unmarshal (jsonConfig , & jobToScrapeConfig )
126
+ if jobToScrapeConfig != nil {
127
+ for _ , scrapeConfig := range jobToScrapeConfig {
128
+ scrapeConfig := scrapeConfig .(map [string ]interface {})
129
+ if scrapeConfig ["relabel_configs" ] != nil {
130
+ relabelConfigs := scrapeConfig ["relabel_configs" ].([]interface {})
131
+ for _ , relabelConfig := range relabelConfigs {
132
+ relabelConfig := relabelConfig .(map [string ]interface {})
133
+ // Dropping regex key from the map since unmarshalling this on the client(metrics_receiver.go) results in error
134
+ // because of the bug here - https://github.com/prometheus/prometheus/issues/12534
135
+ if relabelConfig ["action" ] == "keepequal" || relabelConfig ["action" ] == "dropequal" {
136
+ delete (relabelConfig , "regex" )
137
+ }
138
+ }
139
+ }
140
+ if scrapeConfig ["metric_relabel_configs" ] != nil {
141
+ metricRelabelConfigs := scrapeConfig ["metric_relabel_configs" ].([]interface {})
142
+ for _ , metricRelabelConfig := range metricRelabelConfigs {
143
+ metricRelabelConfig := metricRelabelConfig .(map [string ]interface {})
144
+ // Dropping regex key from the map since unmarshalling this on the client(metrics_receiver.go) results in error
145
+ // because of the bug here - https://github.com/prometheus/prometheus/issues/12534
146
+ if metricRelabelConfig ["action" ] == "keepequal" || metricRelabelConfig ["action" ] == "dropequal" {
147
+ delete (metricRelabelConfig , "regex" )
148
+ }
149
+ }
150
+ }
151
+ }
152
+ }
153
+
154
+ jsonConfigNew , err := json .Marshal (jobToScrapeConfig )
155
+ if err != nil {
156
+ return err
157
+ }
158
+
123
159
s .mtx .Lock ()
124
- s .scrapeConfigResponse = jsonConfig
160
+ s .scrapeConfigResponse = jsonConfigNew
125
161
s .mtx .Unlock ()
126
162
return nil
127
163
}
0 commit comments