- 
                Notifications
    You must be signed in to change notification settings 
- Fork 19
Open
Labels
bugSomething isn't workingSomething isn't working
Description
I think there's an issue with how Lambda Promtail is setting up Relabelling configurations before they're validated, and it's resulting in the following errors:
invalid relabel config: invalid relabel config: labelkeep action requires only 'regex', and no other fields
A basic relabelling configuration that produces an error is:
[
    {
        "regex": "(.*)",
        "action": "labelkeep"
    }
]The issues appears to stem from how SourceLabels are being setup for actions that cannot have source_labels set, such as labelkeep & labeldrop:
	sourceLabels := make(model.LabelNames, 0, len(rc.SourceLabels))
	for _, l := range rc.SourceLabels {
		sourceLabels = append(sourceLabels, model.LabelName(l))
	}
	cfg := &relabel.Config{
		SourceLabels: sourceLabels,
		Separator:    separator,
		Regex:        regex,
		Modulus:      rc.Modulus,
		TargetLabel:  rc.TargetLabel,
		Replacement:  replacement,
		Action:       action,
	}The issue arises when this go is hit in the Validate function, specifically the c.SourceLabels != nil conditional, that evaluates to true because SourceLabels are being set:
	if c.Action == LabelDrop || c.Action == LabelKeep {
		if c.SourceLabels != nil ||
			c.TargetLabel != DefaultRelabelConfig.TargetLabel ||
			c.Modulus != DefaultRelabelConfig.Modulus ||
			c.Separator != DefaultRelabelConfig.Separator ||
			c.Replacement != DefaultRelabelConfig.Replacement {
			return fmt.Errorf("%s action requires only 'regex', and no other fields", c.Action)
		}
	}Metadata
Metadata
Assignees
Labels
bugSomething isn't workingSomething isn't working