diff --git a/model/relabel/relabel.go b/model/relabel/relabel.go index 692ed66c1..3b4249234 100644 --- a/model/relabel/relabel.go +++ b/model/relabel/relabel.go @@ -111,15 +111,6 @@ func (c *Config) UnmarshalYAML(unmarshal func(interface{}) error) error { return c.Validate() } -// MarshalYAML implements the yaml.Marshaler interface. -func (c Config) MarshalYAML() (interface{}, error) { - // Omit the regex if it is the default regex as it was not provided in the first place. - if c.Regex == DefaultRelabelConfig.Regex { - c.Regex.Regexp = nil - } - return c, nil -} - func (c *Config) Validate() error { if c.Action == "" { return fmt.Errorf("relabel action cannot be empty") @@ -214,6 +205,11 @@ func (re Regexp) MarshalYAML() (interface{}, error) { return nil, nil } +// IsZero implements the yaml.IsZeroer interface. +func (re Regexp) IsZero() bool { + return re.Regexp == DefaultRelabelConfig.Regex.Regexp +} + // String returns the original string used to compile the regular expression. func (re Regexp) String() string { str := re.Regexp.String()