diff --git a/discovery/gce/gce.go b/discovery/gce/gce.go index b92336d0d2..4a9cae8916 100644 --- a/discovery/gce/gce.go +++ b/discovery/gce/gce.go @@ -17,6 +17,7 @@ import ( "context" "fmt" "net/http" + "strconv" "strings" "time" @@ -40,6 +41,7 @@ const ( gceLabelSubnetwork = gceLabel + "subnetwork" gceLabelPublicIP = gceLabel + "public_ip" gceLabelPrivateIP = gceLabel + "private_ip" + gceLabelInstanceID = gceLabel + "instance_id" gceLabelInstanceName = gceLabel + "instance_name" gceLabelInstanceStatus = gceLabel + "instance_status" gceLabelTags = gceLabel + "tags" @@ -209,6 +211,7 @@ func (d *Discovery) refresh() (tg *targetgroup.Group, err error) { labels := model.LabelSet{ gceLabelProject: model.LabelValue(d.project), gceLabelZone: model.LabelValue(inst.Zone), + gceLabelInstanceID: model.LabelValue(strconv.FormatUint(inst.Id, 10)), gceLabelInstanceName: model.LabelValue(inst.Name), gceLabelInstanceStatus: model.LabelValue(inst.Status), gceLabelMachineType: model.LabelValue(inst.MachineType), diff --git a/docs/configuration/configuration.md b/docs/configuration/configuration.md index 8fc479963b..9c97002ace 100644 --- a/docs/configuration/configuration.md +++ b/docs/configuration/configuration.md @@ -589,6 +589,7 @@ address with relabeling. 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_label_`: each GCE label of the instance * `__meta_gce_machine_type`: full or partial URL of the machine type of the instance