mirror of
https://github.com/prometheus/prometheus.git
synced 2024-12-25 05:34:05 -08:00
Add common HTTP client to AWS SDs (#11611)
* Common client in EC2 and Lightsail Signed-off-by: Levi Harrison <git@leviharrison.dev> * Azure -> AWS Signed-off-by: Levi Harrison <git@leviharrison.dev> Signed-off-by: Levi Harrison <git@leviharrison.dev>
This commit is contained in:
parent
8b48e36933
commit
f81fae2414
|
@ -586,6 +586,7 @@ var expectedConf = &Config{
|
||||||
Values: []string{"web", "db"},
|
Values: []string{"web", "db"},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
HTTPClientConfig: config.DefaultHTTPClientConfig,
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
@ -602,12 +603,13 @@ var expectedConf = &Config{
|
||||||
|
|
||||||
ServiceDiscoveryConfigs: discovery.Configs{
|
ServiceDiscoveryConfigs: discovery.Configs{
|
||||||
&aws.LightsailSDConfig{
|
&aws.LightsailSDConfig{
|
||||||
Region: "us-east-1",
|
Region: "us-east-1",
|
||||||
AccessKey: "access",
|
AccessKey: "access",
|
||||||
SecretKey: "mysecret",
|
SecretKey: "mysecret",
|
||||||
Profile: "profile",
|
Profile: "profile",
|
||||||
RefreshInterval: model.Duration(60 * time.Second),
|
RefreshInterval: model.Duration(60 * time.Second),
|
||||||
Port: 80,
|
Port: 80,
|
||||||
|
HTTPClientConfig: config.DefaultHTTPClientConfig,
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
|
|
@ -66,8 +66,9 @@ const (
|
||||||
|
|
||||||
// DefaultEC2SDConfig is the default EC2 SD configuration.
|
// DefaultEC2SDConfig is the default EC2 SD configuration.
|
||||||
var DefaultEC2SDConfig = EC2SDConfig{
|
var DefaultEC2SDConfig = EC2SDConfig{
|
||||||
Port: 80,
|
Port: 80,
|
||||||
RefreshInterval: model.Duration(60 * time.Second),
|
RefreshInterval: model.Duration(60 * time.Second),
|
||||||
|
HTTPClientConfig: config.DefaultHTTPClientConfig,
|
||||||
}
|
}
|
||||||
|
|
||||||
func init() {
|
func init() {
|
||||||
|
@ -91,6 +92,8 @@ type EC2SDConfig struct {
|
||||||
RefreshInterval model.Duration `yaml:"refresh_interval,omitempty"`
|
RefreshInterval model.Duration `yaml:"refresh_interval,omitempty"`
|
||||||
Port int `yaml:"port"`
|
Port int `yaml:"port"`
|
||||||
Filters []*EC2Filter `yaml:"filters"`
|
Filters []*EC2Filter `yaml:"filters"`
|
||||||
|
|
||||||
|
HTTPClientConfig config.HTTPClientConfig `yaml:",inline"`
|
||||||
}
|
}
|
||||||
|
|
||||||
// Name returns the name of the EC2 Config.
|
// Name returns the name of the EC2 Config.
|
||||||
|
@ -171,11 +174,17 @@ func (d *EC2Discovery) ec2Client(ctx context.Context) (*ec2.EC2, error) {
|
||||||
creds = nil
|
creds = nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
client, err := config.NewClientFromConfig(d.cfg.HTTPClientConfig, "ec2_sd")
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
|
||||||
sess, err := session.NewSessionWithOptions(session.Options{
|
sess, err := session.NewSessionWithOptions(session.Options{
|
||||||
Config: aws.Config{
|
Config: aws.Config{
|
||||||
Endpoint: &d.cfg.Endpoint,
|
Endpoint: &d.cfg.Endpoint,
|
||||||
Region: &d.cfg.Region,
|
Region: &d.cfg.Region,
|
||||||
Credentials: creds,
|
Credentials: creds,
|
||||||
|
HTTPClient: client,
|
||||||
},
|
},
|
||||||
Profile: d.cfg.Profile,
|
Profile: d.cfg.Profile,
|
||||||
})
|
})
|
||||||
|
|
|
@ -56,8 +56,9 @@ const (
|
||||||
|
|
||||||
// DefaultLightsailSDConfig is the default Lightsail SD configuration.
|
// DefaultLightsailSDConfig is the default Lightsail SD configuration.
|
||||||
var DefaultLightsailSDConfig = LightsailSDConfig{
|
var DefaultLightsailSDConfig = LightsailSDConfig{
|
||||||
Port: 80,
|
Port: 80,
|
||||||
RefreshInterval: model.Duration(60 * time.Second),
|
RefreshInterval: model.Duration(60 * time.Second),
|
||||||
|
HTTPClientConfig: config.DefaultHTTPClientConfig,
|
||||||
}
|
}
|
||||||
|
|
||||||
func init() {
|
func init() {
|
||||||
|
@ -74,6 +75,8 @@ type LightsailSDConfig struct {
|
||||||
RoleARN string `yaml:"role_arn,omitempty"`
|
RoleARN string `yaml:"role_arn,omitempty"`
|
||||||
RefreshInterval model.Duration `yaml:"refresh_interval,omitempty"`
|
RefreshInterval model.Duration `yaml:"refresh_interval,omitempty"`
|
||||||
Port int `yaml:"port"`
|
Port int `yaml:"port"`
|
||||||
|
|
||||||
|
HTTPClientConfig config.HTTPClientConfig `yaml:",inline"`
|
||||||
}
|
}
|
||||||
|
|
||||||
// Name returns the name of the Lightsail Config.
|
// Name returns the name of the Lightsail Config.
|
||||||
|
@ -144,11 +147,17 @@ func (d *LightsailDiscovery) lightsailClient() (*lightsail.Lightsail, error) {
|
||||||
creds = nil
|
creds = nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
client, err := config.NewClientFromConfig(d.cfg.HTTPClientConfig, "lightsail_sd")
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
|
||||||
sess, err := session.NewSessionWithOptions(session.Options{
|
sess, err := session.NewSessionWithOptions(session.Options{
|
||||||
Config: aws.Config{
|
Config: aws.Config{
|
||||||
Endpoint: &d.cfg.Endpoint,
|
Endpoint: &d.cfg.Endpoint,
|
||||||
Region: &d.cfg.Region,
|
Region: &d.cfg.Region,
|
||||||
Credentials: creds,
|
Credentials: creds,
|
||||||
|
HTTPClient: client,
|
||||||
},
|
},
|
||||||
Profile: d.cfg.Profile,
|
Profile: d.cfg.Profile,
|
||||||
})
|
})
|
||||||
|
|
|
@ -1064,6 +1064,45 @@ See below for the configuration options for EC2 discovery:
|
||||||
filters:
|
filters:
|
||||||
[ - name: <string>
|
[ - name: <string>
|
||||||
values: <string>, [...] ]
|
values: <string>, [...] ]
|
||||||
|
|
||||||
|
# Authentication information used to authenticate to the EC2 API.
|
||||||
|
# Note that `basic_auth`, `authorization` and `oauth2` options are
|
||||||
|
# mutually exclusive.
|
||||||
|
# `password` and `password_file` are mutually exclusive.
|
||||||
|
|
||||||
|
# Optional HTTP basic authentication information, currently not supported by AWS.
|
||||||
|
basic_auth:
|
||||||
|
[ username: <string> ]
|
||||||
|
[ password: <secret> ]
|
||||||
|
[ password_file: <string> ]
|
||||||
|
|
||||||
|
# Optional `Authorization` header configuration, currently not supported by AWS.
|
||||||
|
authorization:
|
||||||
|
# Sets the authentication type.
|
||||||
|
[ type: <string> | default: Bearer ]
|
||||||
|
# Sets the credentials. It is mutually exclusive with
|
||||||
|
# `credentials_file`.
|
||||||
|
[ credentials: <secret> ]
|
||||||
|
# Sets the credentials to the credentials read from the configured file.
|
||||||
|
# It is mutuall exclusive with `credentials`.
|
||||||
|
[ credentials_file: <filename> ]
|
||||||
|
|
||||||
|
# Optional OAuth 2.0 configuration, currently not supported by AWS.
|
||||||
|
oauth2:
|
||||||
|
[ <oauth2> ]
|
||||||
|
|
||||||
|
# Optional proxy URL.
|
||||||
|
[ proxy_url: <string> ]
|
||||||
|
|
||||||
|
# Configure whether HTTP requests follow HTTP 3xx redirects.
|
||||||
|
[ follow_redirects: <boolean> | default = true ]
|
||||||
|
|
||||||
|
# Whether to enable HTTP2.
|
||||||
|
[ enable_http2: <bool> | default: true ]
|
||||||
|
|
||||||
|
# TLS configuration.
|
||||||
|
tls_config:
|
||||||
|
[ <tls_config> ]
|
||||||
```
|
```
|
||||||
|
|
||||||
The [relabeling phase](#relabel_config) is the preferred and more powerful
|
The [relabeling phase](#relabel_config) is the preferred and more powerful
|
||||||
|
@ -2066,6 +2105,45 @@ See below for the configuration options for Lightsail discovery:
|
||||||
# The port to scrape metrics from. If using the public IP address, this must
|
# The port to scrape metrics from. If using the public IP address, this must
|
||||||
# instead be specified in the relabeling rule.
|
# instead be specified in the relabeling rule.
|
||||||
[ port: <int> | default = 80 ]
|
[ port: <int> | default = 80 ]
|
||||||
|
|
||||||
|
# Authentication information used to authenticate to the Lightsail API.
|
||||||
|
# Note that `basic_auth`, `authorization` and `oauth2` options are
|
||||||
|
# mutually exclusive.
|
||||||
|
# `password` and `password_file` are mutually exclusive.
|
||||||
|
|
||||||
|
# Optional HTTP basic authentication information, currently not supported by AWS.
|
||||||
|
basic_auth:
|
||||||
|
[ username: <string> ]
|
||||||
|
[ password: <secret> ]
|
||||||
|
[ password_file: <string> ]
|
||||||
|
|
||||||
|
# Optional `Authorization` header configuration, currently not supported by AWS.
|
||||||
|
authorization:
|
||||||
|
# Sets the authentication type.
|
||||||
|
[ type: <string> | default: Bearer ]
|
||||||
|
# Sets the credentials. It is mutually exclusive with
|
||||||
|
# `credentials_file`.
|
||||||
|
[ credentials: <secret> ]
|
||||||
|
# Sets the credentials to the credentials read from the configured file.
|
||||||
|
# It is mutuall exclusive with `credentials`.
|
||||||
|
[ credentials_file: <filename> ]
|
||||||
|
|
||||||
|
# Optional OAuth 2.0 configuration, currently not supported by AWS.
|
||||||
|
oauth2:
|
||||||
|
[ <oauth2> ]
|
||||||
|
|
||||||
|
# Optional proxy URL.
|
||||||
|
[ proxy_url: <string> ]
|
||||||
|
|
||||||
|
# Configure whether HTTP requests follow HTTP 3xx redirects.
|
||||||
|
[ follow_redirects: <boolean> | default = true ]
|
||||||
|
|
||||||
|
# Whether to enable HTTP2.
|
||||||
|
[ enable_http2: <bool> | default: true ]
|
||||||
|
|
||||||
|
# TLS configuration.
|
||||||
|
tls_config:
|
||||||
|
[ <tls_config> ]
|
||||||
```
|
```
|
||||||
|
|
||||||
### `<linode_sd_config>`
|
### `<linode_sd_config>`
|
||||||
|
|
Loading…
Reference in a new issue