diff --git a/config/config.go b/config/config.go index c00e767d40..9466a2d7cc 100644 --- a/config/config.go +++ b/config/config.go @@ -380,7 +380,7 @@ func (c *GlobalConfig) UnmarshalYAML(unmarshal func(interface{}) error) error { if err := unmarshal((*plain)(gc)); err != nil { return err } - if err := checkOverflow(c.XXX, "global config"); err != nil { + if err := checkOverflow(gc.XXX, "global config"); err != nil { return err } // First set the correct scrape interval, then check that the timeout diff --git a/config/config_test.go b/config/config_test.go index a939fb70af..563fbb03de 100644 --- a/config/config_test.go +++ b/config/config_test.go @@ -639,6 +639,9 @@ var expectedErrors = []struct { }, { filename: "target_label_hashmod_missing.bad.yml", errMsg: "relabel configuration for hashmod action requires 'target_label' value", + }, { + filename: "unknown_global_attr.bad.yml", + errMsg: "unknown fields in global config: nonexistent_field", }, } diff --git a/config/testdata/unknown_global_attr.bad.yml b/config/testdata/unknown_global_attr.bad.yml new file mode 100644 index 0000000000..169391f9c6 --- /dev/null +++ b/config/testdata/unknown_global_attr.bad.yml @@ -0,0 +1,2 @@ +global: + nonexistent_field: test