Skip to content

Commit

Permalink
fix for converter relabel source_labels (#4708)
Browse files Browse the repository at this point in the history
Signed-off-by: erikbaranowski <[email protected]>
  • Loading branch information
erikbaranowski authored Aug 4, 2023
1 parent 8bc17c0 commit cc68f26
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 9 deletions.
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,8 @@ Main (unreleased)

### Bugfixes

- Update to config converter so default relabel `source_labels` are left off the river output. (@erikbaranowski)

- Rename `GrafanaAgentManagement` mixin rules to `GrafanaAgentConfig` and update individual alerts to be more accurate. (@spartan0x117)

- Fix potential goroutine leak in log file tailing in static mode. (@thampiotr)
Expand Down
9 changes: 6 additions & 3 deletions converter/internal/prometheusconvert/relabel.go
Original file line number Diff line number Diff line change
Expand Up @@ -67,9 +67,12 @@ func ToFlowRelabelConfigs(relabelConfigs []*prom_relabel.Config) []*flow_relabel

var metricRelabelConfigs []*flow_relabel.Config
for _, relabelConfig := range relabelConfigs {
sourceLabels := make([]string, len(relabelConfig.SourceLabels))
for i, sourceLabel := range relabelConfig.SourceLabels {
sourceLabels[i] = string(sourceLabel)
var sourceLabels []string
if len(relabelConfig.SourceLabels) > 0 {
sourceLabels = make([]string, len(relabelConfig.SourceLabels))
for i, sourceLabel := range relabelConfig.SourceLabels {
sourceLabels[i] = string(sourceLabel)
}
}

metricRelabelConfigs = append(metricRelabelConfigs, &flow_relabel.Config{
Expand Down
5 changes: 2 additions & 3 deletions converter/internal/staticconvert/testdata/integrations.river
Original file line number Diff line number Diff line change
Expand Up @@ -35,9 +35,8 @@ discovery.relabel "integrations_node_exporter" {
}

rule {
source_labels = []
target_label = "__address__"
replacement = "localhost:8099"
target_label = "__address__"
replacement = "localhost:8099"
}
}

Expand Down
5 changes: 2 additions & 3 deletions converter/internal/staticconvert/testdata/prom_scrape.river
Original file line number Diff line number Diff line change
Expand Up @@ -52,9 +52,8 @@ discovery.relabel "metrics_agent_promobee" {
}

rule {
source_labels = []
target_label = "__address__"
replacement = "localhost:8099"
target_label = "__address__"
replacement = "localhost:8099"
}
}

Expand Down

0 comments on commit cc68f26

Please sign in to comment.