simplify regex

This commit is contained in:
Matti Savolainen 2016-10-11 22:00:14 +03:00
parent 23be3dab53
commit bdaf0ec6a2
1 changed files with 3 additions and 3 deletions

View File

@ -350,21 +350,21 @@ func TestRelabel(t *testing.T) {
relabel: []*config.RelabelConfig{
{
SourceLabels: model.LabelNames{"__meta_sd_tags"},
Regex: config.MustNewRegexp(".*?(?:,|^)path:(/[^,]+).*"),
Regex: config.MustNewRegexp("(?:.+,|^)path:(/[^,]+).*"),
Action: config.RelabelReplace,
Replacement: "${1}",
TargetLabel: model.LabelName("__metrics_path__"),
},
{
SourceLabels: model.LabelNames{"__meta_sd_tags"},
Regex: config.MustNewRegexp(".*?(?:,|^)job:([^,]+).*"),
Regex: config.MustNewRegexp("(?:.+,|^)job:([^,]+).*"),
Action: config.RelabelReplace,
Replacement: "${1}",
TargetLabel: model.LabelName("job"),
},
{
SourceLabels: model.LabelNames{"__meta_sd_tags"},
Regex: config.MustNewRegexp(".*?(?:,|^)label:([^=]+)=([^,]+).*"),
Regex: config.MustNewRegexp("(?:.+,|^)label:([^=]+)=([^,]+).*"),
Action: config.RelabelReplace,
Replacement: "${2}",
TargetLabel: model.LabelName("${1}"),