lib/promscrape/discovery/gce: add __meta_gce_interface_ipv4_<name> labels as in Prometheus 2.29

See https://github.com/prometheus/prometheus/pull/8978
This commit is contained in:
Aliaksandr Valialkin 2021-08-03 15:47:25 +03:00
parent 336a2aa2e0
commit 77bb9e1656
3 changed files with 8 additions and 1 deletions

View File

@ -7,7 +7,8 @@ sort: 15
## tip
* FEATURE: add `present_over_time(m[d])` function, which returns 1 if `m` has a least a single sample over the previous duration `d`. This function has been added also to [Prometheus 2.29](https://github.com/prometheus/prometheus/releases/tag/v2.29.0-rc.0).
* FEATURE: vmagent: add `__meta_ec2_availability_zone_id` label, which has been introduced in [Prometheus 2.29](https://github.com/prometheus/prometheus/releases/tag/v2.29.0-rc.0).
* FEATURE: vmagent: add `__meta_ec2_availability_zone_id` label to discovered Amazon EC2 targets. This label is available in Prometheus [starting from v2.29](https://github.com/prometheus/prometheus/releases/tag/v2.29.0-rc.0).
* FAETURE: vmagent: add `__meta_gce_interface_ipv4_<name>` labels to discovered GCE targets. These labels are available in Prometheus [starting from v2.29](https://github.com/prometheus/prometheus/releases/tag/v2.29.0-rc.0).
* FEATURE: add `-search.maxSamplesPerSeries` command-line flag for limiting the number of raw samples a single query can process per each time series. This option can protect from out of memory errors when a query processes tens of millions of raw samples per series. See [this issue](https://github.com/VictoriaMetrics/VictoriaMetrics/issues/1067).
* FEATURE: add `-search.maxSamplesPerQuery` command-line flag for limiting the number of raw samples a single query can process across all the time series. This option can protect from heavy queries, which select too big number of raw samples. Thanks to @jiangxinlingdu for [the initial pull request](https://github.com/VictoriaMetrics/VictoriaMetrics/pull/1478).
* FEATURE: improve performance for queries that process big number of time series and/or samples on systems with big number of CPU cores.

View File

@ -93,6 +93,7 @@ type Instance struct {
// NetworkInterface is network interface from https://cloud.google.com/compute/docs/reference/rest/v1/instances/list
type NetworkInterface struct {
Name string
Network string
Subnetwork string
NetworkIP string
@ -148,6 +149,10 @@ func (inst *Instance) appendTargetLabels(ms []map[string]string, project, tagSep
"__meta_gce_subnetwork": iface.Subnetwork,
"__meta_gce_zone": inst.Zone,
}
for _, iface := range inst.NetworkInterfaces {
ifaceName := discoveryutils.SanitizeLabelName(iface.Name)
m["__meta_gce_interface_ipv4_"+ifaceName] = iface.NetworkIP
}
if len(inst.Tags.Items) > 0 {
// We surround the separated list with the separator as well. This way regular expressions
// in relabeling rules don't have to consider tag positions.

View File

@ -158,6 +158,7 @@ func TestParseInstanceListSuccess(t *testing.T) {
"__meta_gce_instance_id": "7897352091592122",
"__meta_gce_instance_name": "play-1m-1-vmagent",
"__meta_gce_instance_status": "RUNNING",
"__meta_gce_interface_ipv4_nic0": "10.11.2.7",
"__meta_gce_label_cluster_num": "1",
"__meta_gce_label_cluster_retention": "1m",
"__meta_gce_label_env": "play",