app/vmagent: do not allow non-supported fields in -remoteWrite.relabelConfig and file_sd_configs

This should reduce possible confusion like in the https://github.com/VictoriaMetrics/VictoriaMetrics/issues/363
This commit is contained in:
Aliaksandr Valialkin 2020-03-06 20:18:28 +02:00
parent c386c5de57
commit 986dba5ab3
2 changed files with 2 additions and 2 deletions

View File

@ -28,7 +28,7 @@ func LoadRelabelConfigs(path string) ([]ParsedRelabelConfig, error) {
return nil, fmt.Errorf("cannot read `relabel_configs` from %q: %s", path, err) return nil, fmt.Errorf("cannot read `relabel_configs` from %q: %s", path, err)
} }
var rcs []RelabelConfig var rcs []RelabelConfig
if err := yaml.Unmarshal(data, &rcs); err != nil { if err := yaml.UnmarshalStrict(data, &rcs); err != nil {
return nil, fmt.Errorf("cannot unmarshal `relabel_configs` from %q: %s", path, err) return nil, fmt.Errorf("cannot unmarshal `relabel_configs` from %q: %s", path, err)
} }
return ParseRelabelConfigs(nil, rcs) return ParseRelabelConfigs(nil, rcs)

View File

@ -102,7 +102,7 @@ func loadStaticConfigs(path string) ([]StaticConfig, error) {
return nil, fmt.Errorf("cannot read `static_configs` from %q: %s", path, err) return nil, fmt.Errorf("cannot read `static_configs` from %q: %s", path, err)
} }
var stcs []StaticConfig var stcs []StaticConfig
if err := yaml.Unmarshal(data, &stcs); err != nil { if err := yaml.UnmarshalStrict(data, &stcs); err != nil {
return nil, fmt.Errorf("cannot unmarshal `static_configs` from %q: %s", path, err) return nil, fmt.Errorf("cannot unmarshal `static_configs` from %q: %s", path, err)
} }
return stcs, nil return stcs, nil