Merge pull request #4488 from jkohen/patch-3

Populate __meta_gce_instance_id discovery label
This commit is contained in:
Fabian Reinartz 2018-08-11 09:52:28 +02:00 committed by GitHub
commit b04ab71268
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 4 additions and 0 deletions

View file

@ -17,6 +17,7 @@ import (
"context" "context"
"fmt" "fmt"
"net/http" "net/http"
"strconv"
"strings" "strings"
"time" "time"
@ -40,6 +41,7 @@ const (
gceLabelSubnetwork = gceLabel + "subnetwork" gceLabelSubnetwork = gceLabel + "subnetwork"
gceLabelPublicIP = gceLabel + "public_ip" gceLabelPublicIP = gceLabel + "public_ip"
gceLabelPrivateIP = gceLabel + "private_ip" gceLabelPrivateIP = gceLabel + "private_ip"
gceLabelInstanceID = gceLabel + "instance_id"
gceLabelInstanceName = gceLabel + "instance_name" gceLabelInstanceName = gceLabel + "instance_name"
gceLabelInstanceStatus = gceLabel + "instance_status" gceLabelInstanceStatus = gceLabel + "instance_status"
gceLabelTags = gceLabel + "tags" gceLabelTags = gceLabel + "tags"
@ -209,6 +211,7 @@ func (d *Discovery) refresh() (tg *targetgroup.Group, err error) {
labels := model.LabelSet{ labels := model.LabelSet{
gceLabelProject: model.LabelValue(d.project), gceLabelProject: model.LabelValue(d.project),
gceLabelZone: model.LabelValue(inst.Zone), gceLabelZone: model.LabelValue(inst.Zone),
gceLabelInstanceID: model.LabelValue(strconv.FormatUint(inst.Id, 10)),
gceLabelInstanceName: model.LabelValue(inst.Name), gceLabelInstanceName: model.LabelValue(inst.Name),
gceLabelInstanceStatus: model.LabelValue(inst.Status), gceLabelInstanceStatus: model.LabelValue(inst.Status),
gceLabelMachineType: model.LabelValue(inst.MachineType), gceLabelMachineType: model.LabelValue(inst.MachineType),

View file

@ -589,6 +589,7 @@ address with relabeling.
The following meta labels are available on targets during [relabeling](#relabel_config): The following meta labels are available on targets during [relabeling](#relabel_config):
* `__meta_gce_instance_id`: the numeric id of the instance
* `__meta_gce_instance_name`: the name of the instance * `__meta_gce_instance_name`: the name of the instance
* `__meta_gce_label_<name>`: each GCE label of the instance * `__meta_gce_label_<name>`: each GCE label of the instance
* `__meta_gce_machine_type`: full or partial URL of the machine type of the instance * `__meta_gce_machine_type`: full or partial URL of the machine type of the instance