Browse Source

validate the label name

pull/2078/head
Matti Savolainen 8 years ago
parent
commit
8f77d271b1
  1. 10
      relabel/relabel.go

10
relabel/relabel.go

@ -61,17 +61,17 @@ func relabel(labels model.LabelSet, cfg *config.RelabelConfig) model.LabelSet {
if indexes == nil {
break
}
res := cfg.Regex.ExpandString([]byte{}, cfg.Replacement, val, indexes)
if len(res) == 0 {
target := model.LabelName(cfg.Regex.ExpandString([]byte{}, string(cfg.TargetLabel), val, indexes))
if !target.IsValid() {
delete(labels, cfg.TargetLabel)
break
}
target := cfg.Regex.ExpandString([]byte{}, string(cfg.TargetLabel), val, indexes)
if len(target) == 0 {
res := cfg.Regex.ExpandString([]byte{}, cfg.Replacement, val, indexes)
if len(res) == 0 {
delete(labels, cfg.TargetLabel)
break
}
labels[model.LabelName(target)] = model.LabelValue(res)
labels[target] = model.LabelValue(res)
case config.RelabelHashMod:
mod := sum64(md5.Sum([]byte(val))) % cfg.Modulus
labels[cfg.TargetLabel] = model.LabelValue(fmt.Sprintf("%d", mod))

Loading…
Cancel
Save