Skip to content

Commit 3542e28

Browse files
fix
1 parent dab898f commit 3542e28

File tree

2 files changed

+53
-1
lines changed

2 files changed

+53
-1
lines changed
+16
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
# One of 'breaking', 'deprecation', 'new_component', 'enhancement', 'bug_fix'
2+
change_type: bug_fix
3+
4+
# The name of the component, or a single word describing the area of concern, (e.g. operator, target allocator, github action)
5+
component: target allocator
6+
7+
# A brief description of the change. Surround your text with quotes ("") if it needs to start with a backtick (`).
8+
note: Fix for keepequal/dropequal action
9+
10+
# One or more tracking issues related to the change
11+
issues: [2793]
12+
13+
# (Optional) One or more lines of additional information to render under the primary note.
14+
# These lines will be padded with 2 spaces and then inserted directly into the document.
15+
# Use pipe (|) for multiline entries.
16+
subtext:

cmd/otel-allocator/server/server.go

+37-1
Original file line numberDiff line numberDiff line change
@@ -120,8 +120,44 @@ func (s *Server) UpdateScrapeConfigResponse(configs map[string]*promconfig.Scrap
120120
if err != nil {
121121
return err
122122
}
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+
123159
s.mtx.Lock()
124-
s.scrapeConfigResponse = jsonConfig
160+
s.scrapeConfigResponse = jsonConfigNew
125161
s.mtx.Unlock()
126162
return nil
127163
}

0 commit comments

Comments
 (0)