mirror of
https://github.com/VictoriaMetrics/VictoriaMetrics.git
synced 2024-12-15 08:23:34 +01:00
lib/promscrape: expose __meta_ec2_ipv6_addresses
label for ec2_sd_config
like Prometheus will do in the next release
This commit is contained in:
parent
c2186279b7
commit
8b82f9d8b8
@ -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)).
|
* 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
|
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: 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: 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
|
* 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
|
at the rate exceeding the given limit. See https://github.com/VictoriaMetrics/VictoriaMetrics/issues/905#issuecomment-729395855
|
||||||
|
@ -15,11 +15,11 @@ func TestGetFiltersQueryArg(t *testing.T) {
|
|||||||
f(nil, "")
|
f(nil, "")
|
||||||
f([]Filter{
|
f([]Filter{
|
||||||
{
|
{
|
||||||
Name: "name",
|
Name: "name",
|
||||||
Values: []string{"foo", "bar"},
|
Values: []string{"foo", "bar"},
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
Name: "xxx",
|
Name: "xxx",
|
||||||
Values: []string{"aa"},
|
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")
|
}, "%7B%22name%22%3A%7B%22bar%22%3Atrue%2C%22foo%22%3Atrue%7D%2C%22xxx%22%3A%7B%22aa%22%3Atrue%7D%7D")
|
||||||
|
@ -104,7 +104,13 @@ type NetworkInterfaceSet struct {
|
|||||||
|
|
||||||
// NetworkInterface represents NetworkInterface from https://docs.aws.amazon.com/AWSEC2/latest/APIReference/API_InstanceNetworkInterface.html
|
// NetworkInterface represents NetworkInterface from https://docs.aws.amazon.com/AWSEC2/latest/APIReference/API_InstanceNetworkInterface.html
|
||||||
type NetworkInterface struct {
|
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
|
// 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,
|
"__meta_ec2_vpc_id": inst.VPCID,
|
||||||
}
|
}
|
||||||
if len(inst.VPCID) > 0 {
|
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))
|
subnets := make([]string, 0, len(inst.NetworkInterfaceSet.Items))
|
||||||
seenSubnets := make(map[string]bool, len(inst.NetworkInterfaceSet.Items))
|
seenSubnets := make(map[string]bool, len(inst.NetworkInterfaceSet.Items))
|
||||||
|
var ipv6Addrs []string
|
||||||
for _, ni := range inst.NetworkInterfaceSet.Items {
|
for _, ni := range inst.NetworkInterfaceSet.Items {
|
||||||
if len(ni.SubnetID) == 0 {
|
if len(ni.SubnetID) == 0 {
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
|
// Deduplicate VPC Subnet IDs maintaining the order of the network interfaces returned by EC2.
|
||||||
if !seenSubnets[ni.SubnetID] {
|
if !seenSubnets[ni.SubnetID] {
|
||||||
seenSubnets[ni.SubnetID] = true
|
seenSubnets[ni.SubnetID] = true
|
||||||
subnets = append(subnets, ni.SubnetID)
|
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
|
// We surround the separated list with the separator as well. This way regular expressions
|
||||||
// in relabeling rules don't have to consider tag positions.
|
// in relabeling rules don't have to consider tag positions.
|
||||||
m["__meta_ec2_subnet_id"] = "," + strings.Join(subnets, ",") + ","
|
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 {
|
for _, t := range inst.TagSet.Items {
|
||||||
if len(t.Key) == 0 || len(t.Value) == 0 {
|
if len(t.Key) == 0 || len(t.Value) == 0 {
|
||||||
|
Loading…
Reference in New Issue
Block a user