mirror of
https://github.com/VictoriaMetrics/VictoriaMetrics.git
synced 2025-01-20 07:19:17 +01:00
lib/promscrape/discovery/ec2: add ability to filter Availability Zones in ec2_sd_config
via az_filters
section
This commit is contained in:
parent
8babb4aebc
commit
9d40bb7137
@ -15,6 +15,8 @@ The following tip changes can be tested by building VictoriaMetrics components f
|
|||||||
|
|
||||||
## tip
|
## tip
|
||||||
|
|
||||||
|
* FEATURE: [vmagent](https://docs.victoriametrics.com/vmagent.html): add ability to specify filters for Availability Zones in [ec2_sd_config](https://prometheus.io/docs/prometheus/latest/configuration/configuration/#ec2_sd_config) via `az_filters` section. This section can contain AZ-specific set of filters in the same way as the existing `filters` section, which is used for filtering EC2 instances. The list of supported AZ-specific filters is available [here](https://docs.aws.amazon.com/AWSEC2/latest/APIReference/API_DescribeAvailabilityZones.html).
|
||||||
|
|
||||||
* BUGFIX: [vmctl](https://docs.victoriametrics.com/vmctl.html): properly import InfluxDB measurements if they contain `db` tag. Previously this could result in incomplete import of measurmenet tags. See [this pull request](https://github.com/VictoriaMetrics/VictoriaMetrics/pull/2536). Thanks to @mback2k for the bugfix.
|
* BUGFIX: [vmctl](https://docs.victoriametrics.com/vmctl.html): properly import InfluxDB measurements if they contain `db` tag. Previously this could result in incomplete import of measurmenet tags. See [this pull request](https://github.com/VictoriaMetrics/VictoriaMetrics/pull/2536). Thanks to @mback2k for the bugfix.
|
||||||
* BUGFIX: [vmui](https://docs.victoriametrics.com/#vmui): do not reset the selected relative time range when entering new query. See [this issue](https://github.com/VictoriaMetrics/VictoriaMetrics/issues/2402#issuecomment-1115817302).
|
* BUGFIX: [vmui](https://docs.victoriametrics.com/#vmui): do not reset the selected relative time range when entering new query. See [this issue](https://github.com/VictoriaMetrics/VictoriaMetrics/issues/2402#issuecomment-1115817302).
|
||||||
* BUGFIX: [vmui](https://docs.victoriametrics.com/#vmui): properly show the graph when clicking on `Prometheus` link in Grafana graph editor. Previously the graph wasn't shown until clicking on the `Graph` tab. See [this issue](https://github.com/VictoriaMetrics/VictoriaMetrics/issues/2402#issuecomment-1115830648).
|
* BUGFIX: [vmui](https://docs.victoriametrics.com/#vmui): properly show the graph when clicking on `Prometheus` link in Grafana graph editor. Previously the graph wasn't shown until clicking on the `Graph` tab. See [this issue](https://github.com/VictoriaMetrics/VictoriaMetrics/issues/2402#issuecomment-1115830648).
|
||||||
|
@ -8,9 +8,10 @@ import (
|
|||||||
)
|
)
|
||||||
|
|
||||||
type apiConfig struct {
|
type apiConfig struct {
|
||||||
awsConfig *awsapi.Config
|
awsConfig *awsapi.Config
|
||||||
filters []awsapi.Filter
|
instanceFilters []awsapi.Filter
|
||||||
port int
|
azFilters []awsapi.Filter
|
||||||
|
port int
|
||||||
|
|
||||||
// A map from AZ name to AZ id.
|
// A map from AZ name to AZ id.
|
||||||
azMap map[string]string
|
azMap map[string]string
|
||||||
@ -37,9 +38,10 @@ func newAPIConfig(sdc *SDConfig) (*apiConfig, error) {
|
|||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
cfg := &apiConfig{
|
cfg := &apiConfig{
|
||||||
awsConfig: awsCfg,
|
awsConfig: awsCfg,
|
||||||
filters: sdc.Filters,
|
instanceFilters: sdc.InstanceFilters,
|
||||||
port: port,
|
azFilters: sdc.AZFilters,
|
||||||
|
port: port,
|
||||||
}
|
}
|
||||||
return cfg, nil
|
return cfg, nil
|
||||||
}
|
}
|
||||||
|
@ -30,7 +30,7 @@ func getAZMap(cfg *apiConfig) map[string]string {
|
|||||||
|
|
||||||
func getAvailabilityZones(cfg *apiConfig) ([]AvailabilityZone, error) {
|
func getAvailabilityZones(cfg *apiConfig) ([]AvailabilityZone, error) {
|
||||||
// See https://docs.aws.amazon.com/AWSEC2/latest/APIReference/API_DescribeAvailabilityZones.html
|
// See https://docs.aws.amazon.com/AWSEC2/latest/APIReference/API_DescribeAvailabilityZones.html
|
||||||
azFilters := awsapi.GetFiltersQueryString(cfg.filters, azFiltersWhitelist)
|
azFilters := awsapi.GetFiltersQueryString(cfg.azFilters, azFiltersWhitelist)
|
||||||
data, err := cfg.awsConfig.GetEC2APIResponse("DescribeAvailabilityZones", azFilters, "")
|
data, err := cfg.awsConfig.GetEC2APIResponse("DescribeAvailabilityZones", azFilters, "")
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, fmt.Errorf("cannot obtain availability zones: %w", err)
|
return nil, fmt.Errorf("cannot obtain availability zones: %w", err)
|
||||||
|
@ -27,8 +27,9 @@ type SDConfig struct {
|
|||||||
RoleARN string `yaml:"role_arn,omitempty"`
|
RoleARN string `yaml:"role_arn,omitempty"`
|
||||||
// RefreshInterval time.Duration `yaml:"refresh_interval"`
|
// RefreshInterval time.Duration `yaml:"refresh_interval"`
|
||||||
// refresh_interval is obtained from `-promscrape.ec2SDCheckInterval` command-line option.
|
// refresh_interval is obtained from `-promscrape.ec2SDCheckInterval` command-line option.
|
||||||
Port *int `yaml:"port,omitempty"`
|
Port *int `yaml:"port,omitempty"`
|
||||||
Filters []awsapi.Filter `yaml:"filters,omitempty"`
|
InstanceFilters []awsapi.Filter `yaml:"filters,omitempty"`
|
||||||
|
AZFilters []awsapi.Filter `yaml:"az_filters,omitempty"`
|
||||||
}
|
}
|
||||||
|
|
||||||
// GetLabels returns ec2 labels according to sdc.
|
// GetLabels returns ec2 labels according to sdc.
|
||||||
|
@ -29,7 +29,7 @@ func getReservations(cfg *apiConfig) ([]Reservation, error) {
|
|||||||
// See https://docs.aws.amazon.com/AWSEC2/latest/APIReference/API_DescribeInstances.html
|
// See https://docs.aws.amazon.com/AWSEC2/latest/APIReference/API_DescribeInstances.html
|
||||||
var rs []Reservation
|
var rs []Reservation
|
||||||
pageToken := ""
|
pageToken := ""
|
||||||
instanceFilters := awsapi.GetFiltersQueryString(cfg.filters, nil)
|
instanceFilters := awsapi.GetFiltersQueryString(cfg.instanceFilters, nil)
|
||||||
for {
|
for {
|
||||||
data, err := cfg.awsConfig.GetEC2APIResponse("DescribeInstances", instanceFilters, pageToken)
|
data, err := cfg.awsConfig.GetEC2APIResponse("DescribeInstances", instanceFilters, pageToken)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
Loading…
Reference in New Issue
Block a user