Skip to content

Commit

Permalink
Operator: Add relabel_config.libsonnet to logs templates dir (#1064)
Browse files Browse the repository at this point in the history
* Add relabel_config.libsonnet to logs templates dir
* Update CHANGELOG.md
  • Loading branch information
hjet committed Nov 5, 2021
1 parent 43aeb18 commit a6f8ced
Show file tree
Hide file tree
Showing 3 changed files with 32 additions and 0 deletions.
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@

- [BUGFIX] Operator: Create govern service per Grafana Agent (@shturman)

- [BUGFIX] Operator: Fix relabel_config directive for PodLogs resource (@hjet)

- [CHANGE] Self-scraped integrations will now use an SUO-specific value for the `instance` label. (@rfratto)

# v0.20.0 (2021-10-28)
Expand Down
18 changes: 18 additions & 0 deletions pkg/operator/config/logs_templates_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -474,6 +474,17 @@ func TestPodLogsConfig(t *testing.T) {
Namespace: "operator",
Name: "podlogs",
},
Spec: gragent.PodLogsSpec{
RelabelConfigs: []*prom_v1.RelabelConfig{{
SourceLabels: []string{"input_a", "input_b"},
Separator: ";",
TargetLabel: "target_a",
Regex: "regex",
Modulus: 1234,
Replacement: "foobar",
Action: "replace",
}},
},
},
"apiServer": prom_v1.APIServerConfig{},
"ignoreNamespaceSelectors": false,
Expand Down Expand Up @@ -502,6 +513,13 @@ func TestPodLogsConfig(t *testing.T) {
target_label: __path__
separator: /
replacement: /var/log/pods/*$1/*.log
- source_labels: ["input_a", "input_b"]
separator: ";"
target_label: "target_a"
regex: regex
modulus: 1234
replacement: foobar
action: replace
`),
},
}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
local optionals = import 'ext/optionals.libsonnet';

// @param {RelabelConfig} cfg
function(cfg) {
source_labels: optionals.array(cfg.SourceLabels),
separator: optionals.string(cfg.Separator),
regex: optionals.string(cfg.Regex),
modulus: optionals.number(cfg.Modulus),
target_label: optionals.string(cfg.TargetLabel),
replacement: optionals.string(cfg.Replacement),
action: optionals.string(cfg.Action),
}

0 comments on commit a6f8ced

Please sign in to comment.