diff --git a/docs/CHANGELOG.md b/docs/CHANGELOG.md index 4dccfff4db..66d91bd554 100644 --- a/docs/CHANGELOG.md +++ b/docs/CHANGELOG.md @@ -12,6 +12,7 @@ * FEATURE: vmagent: add Netflix Eureka service discovery (aka [eureka_sd_config](https://prometheus.io/docs/prometheus/latest/configuration/configuration/#eureka_sd_config)). See https://github.com/VictoriaMetrics/VictoriaMetrics/issues/851 * FEATURE: add `filters` option to `dockerswarm_sd_config` like Prometheus did in v2.23.0 - see https://github.com/prometheus/prometheus/pull/8074 +* FEATURE: expose `__meta_ec2_ipv6_addresses` label for `ec2_sd_config` like Prometheus will do in the next release. * FEATURE: add `-loggerWarnsPerSecondLimit` command-line flag for rate limiting of WARN messages in logs. See https://github.com/VictoriaMetrics/VictoriaMetrics/issues/905 * FEATURE: apply `loggerErrorsPerSecondLimit` and `-loggerWarnsPerSecondLimit` rate limit per caller. I.e. log messages are suppressed if the same caller logs the same message at the rate exceeding the given limit. See https://github.com/VictoriaMetrics/VictoriaMetrics/issues/905#issuecomment-729395855 diff --git a/lib/promscrape/discovery/dockerswarm/api_test.go b/lib/promscrape/discovery/dockerswarm/api_test.go index fe36a75a2c..fc8888ee59 100644 --- a/lib/promscrape/discovery/dockerswarm/api_test.go +++ b/lib/promscrape/discovery/dockerswarm/api_test.go @@ -15,11 +15,11 @@ func TestGetFiltersQueryArg(t *testing.T) { f(nil, "") f([]Filter{ { - Name: "name", + Name: "name", Values: []string{"foo", "bar"}, }, { - Name: "xxx", + Name: "xxx", Values: []string{"aa"}, }, }, "%7B%22name%22%3A%7B%22bar%22%3Atrue%2C%22foo%22%3Atrue%7D%2C%22xxx%22%3A%7B%22aa%22%3Atrue%7D%7D") diff --git a/lib/promscrape/discovery/ec2/instance.go b/lib/promscrape/discovery/ec2/instance.go index 7dbf6203ad..45ccfb0cfe 100644 --- a/lib/promscrape/discovery/ec2/instance.go +++ b/lib/promscrape/discovery/ec2/instance.go @@ -104,7 +104,13 @@ type NetworkInterfaceSet struct { // NetworkInterface represents NetworkInterface from https://docs.aws.amazon.com/AWSEC2/latest/APIReference/API_InstanceNetworkInterface.html type NetworkInterface struct { - SubnetID string `xml:"subnetId"` + SubnetID string `xml:"subnetId"` + IPv6AddressesSet Ipv6AddressesSet `xml:"ipv6AddressesSet"` +} + +// Ipv6AddressesSet represents ipv6AddressesSet from https://docs.aws.amazon.com/AWSEC2/latest/APIReference/API_InstanceNetworkInterface.html +type Ipv6AddressesSet struct { + Items []string `xml:"item"` } // TagSet represents TagSet from https://docs.aws.amazon.com/AWSEC2/latest/APIReference/API_Instance.html @@ -151,21 +157,27 @@ func (inst *Instance) appendTargetLabels(ms []map[string]string, ownerID string, "__meta_ec2_vpc_id": inst.VPCID, } if len(inst.VPCID) > 0 { - // Deduplicate VPC Subnet IDs maintaining the order of the network interfaces returned by EC2. subnets := make([]string, 0, len(inst.NetworkInterfaceSet.Items)) seenSubnets := make(map[string]bool, len(inst.NetworkInterfaceSet.Items)) + var ipv6Addrs []string for _, ni := range inst.NetworkInterfaceSet.Items { if len(ni.SubnetID) == 0 { continue } + // Deduplicate VPC Subnet IDs maintaining the order of the network interfaces returned by EC2. if !seenSubnets[ni.SubnetID] { seenSubnets[ni.SubnetID] = true subnets = append(subnets, ni.SubnetID) } + // Collect ipv6 addresses + ipv6Addrs = append(ipv6Addrs, ni.IPv6AddressesSet.Items...) } // We surround the separated list with the separator as well. This way regular expressions // in relabeling rules don't have to consider tag positions. m["__meta_ec2_subnet_id"] = "," + strings.Join(subnets, ",") + "," + if len(ipv6Addrs) > 0 { + m["__meta_ec2_ipv6_addresses"] = "," + strings.Join(ipv6Addrs, ",") + "," + } } for _, t := range inst.TagSet.Items { if len(t.Key) == 0 || len(t.Value) == 0 {