Merge pull request #12811 from slashpai/sd_validate

EC2 SD: Validate HTTP config
This commit is contained in:
Julien Pivotto 2023-09-08 09:59:42 +02:00 committed by GitHub
commit 92f463a51d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 11 additions and 1 deletions

View File

@ -1745,6 +1745,10 @@ var expectedErrors = []struct {
filename: "ec2_filters_empty_values.bad.yml",
errMsg: `EC2 SD configuration filter values cannot be empty`,
},
{
filename: "ec2_token_file.bad.yml",
errMsg: `at most one of bearer_token & bearer_token_file must be configured`,
},
{
filename: "section_key_dup.bad.yml",
errMsg: "field scrape_configs already set in type config.plain",

View File

@ -0,0 +1,6 @@
scrape_configs:
- job_name: foo
ec2_sd_configs:
- region: us-east-1
bearer_token: foo
bearer_token_file: foo

View File

@ -129,7 +129,7 @@ func (c *EC2SDConfig) UnmarshalYAML(unmarshal func(interface{}) error) error {
return errors.New("EC2 SD configuration filter values cannot be empty")
}
}
return nil
return c.HTTPClientConfig.Validate()
}
// EC2Discovery periodically performs EC2-SD requests. It implements