code: func (c *Config) UnmarshalYAML(unmarshal func(interface{}) error) error {
  	*c = DefaultRelabelConfig
  	type plain Config
  	if err := unmarshal((*plain)(c)); err != nil {
  		return err
  	}
  	if c.Regex.Regexp == nil {
  		c.Regex = MustNewRegexp("")
  	}
  	if c.Modulus == 0 && c.Action == HashMod {
  		return errors.Errorf("relabel configuration for hashmod requires non-zero modulus")
  	}
  	if (c.Action == Replace || c.Action == HashMod) && c.TargetLabel == "" {
  		return errors.Errorf("relabel configuration for %s action requires 'target_label' value", c.Action)
  	}
  	if c.Action == Replace && !relabelTarget.MatchString(c.TargetLabel) {
  		return errors.Errorf("%q is invalid 'target_label' for %s action", c.TargetLabel, c.Action)
  	}
  	if c.Action == LabelMap && !relabelTarget.MatchString(c.Replacement) {
  		return errors.Errorf("%q is invalid 'replacement' for %s action", c.Replacement, c.Action)
  	}
  	if c.Action == HashMod && !model.LabelName(c.TargetLabel).IsValid() {
  		return errors.Errorf("%q is invalid 'target_label' for %s action", c.TargetLabel, c.Action)
  	}
  
  	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 errors.Errorf("%s action requires only 'regex', and no other fields", c.Action)
  		}
  	}
  
  	return nil
  }
docs: // UnmarshalYAML implements the yaml.Unmarshaler interface.