Merge pull request #8978 from jfreeland/feat/additional-gce-interfaces

feat: explicit gce interface ipv4 address metadata
This commit is contained in:
Julien Pivotto 2021-07-26 19:38:59 +02:00 committed by GitHub
commit dcba645366
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 7 additions and 0 deletions

View file

@ -178,6 +178,12 @@ func (d *Discovery) refresh(ctx context.Context) ([]*targetgroup.Group, error) {
addr := fmt.Sprintf("%s:%d", priIface.NetworkIP, d.port)
labels[model.AddressLabel] = model.LabelValue(addr)
// Append named interface metadata for all interfaces
for _, iface := range inst.NetworkInterfaces {
gceLabelNetAddress := model.LabelName(fmt.Sprintf("%sinterface_ipv4_%s", gceLabel, strutil.SanitizeLabelName(iface.Name)))
labels[gceLabelNetAddress] = model.LabelValue(iface.NetworkIP)
}
// Tags in GCE are usually only used for networking rules.
if inst.Tags != nil && len(inst.Tags.Items) > 0 {
// We surround the separated list with the separator as well. This way regular expressions

View file

@ -1136,6 +1136,7 @@ The following meta labels are available on targets during [relabeling](#relabel_
* `__meta_gce_metadata_<name>`: each metadata item of the instance
* `__meta_gce_network`: the network URL of the instance
* `__meta_gce_private_ip`: the private IP address of the instance
* `__meta_gce_interface_ipv4_<name>`: IPv4 address of each named interface
* `__meta_gce_project`: the GCP project in which the instance is running
* `__meta_gce_public_ip`: the public IP address of the instance, if present
* `__meta_gce_subnetwork`: the subnetwork URL of the instance