Add GCE Instance Status

This commit is contained in:
Dominik Schulz 2016-10-08 08:40:12 +02:00
parent 0cf8586136
commit c73aa82589

View file

@ -32,15 +32,16 @@ import (
) )
const ( const (
gceLabel = model.MetaLabelPrefix + "gce_" gceLabel = model.MetaLabelPrefix + "gce_"
gceLabelProject = gceLabel + "project" gceLabelProject = gceLabel + "project"
gceLabelZone = gceLabel + "zone" gceLabelZone = gceLabel + "zone"
gceLabelNetwork = gceLabel + "network" gceLabelNetwork = gceLabel + "network"
gceLabelSubnetwork = gceLabel + "subnetwork" gceLabelSubnetwork = gceLabel + "subnetwork"
gceLabelPublicIP = gceLabel + "public_ip" gceLabelPublicIP = gceLabel + "public_ip"
gceLabelPrivateIP = gceLabel + "private_ip" gceLabelPrivateIP = gceLabel + "private_ip"
gceLabelInstanceName = gceLabel + "instance_name" gceLabelInstanceName = gceLabel + "instance_name"
gceLabelTags = gceLabel + "tags" gceLabelInstanceStatus = gceLabel + "instance_status"
gceLabelTags = gceLabel + "tags"
// Constants for instrumentation. // Constants for instrumentation.
namespace = "prometheus" namespace = "prometheus"
@ -164,9 +165,10 @@ func (gd *GCEDiscovery) refresh() (tg *config.TargetGroup, err error) {
continue continue
} }
labels := model.LabelSet{ labels := model.LabelSet{
gceLabelProject: model.LabelValue(gd.project), gceLabelProject: model.LabelValue(gd.project),
gceLabelZone: model.LabelValue(inst.Zone), gceLabelZone: model.LabelValue(inst.Zone),
gceLabelInstanceName: model.LabelValue(inst.Name), gceLabelInstanceName: model.LabelValue(inst.Name),
gceLabelInstanceStatus: model.LabelValue(inst.Status),
} }
priIface := inst.NetworkInterfaces[0] priIface := inst.NetworkInterfaces[0]
labels[gceLabelNetwork] = model.LabelValue(priIface.Network) labels[gceLabelNetwork] = model.LabelValue(priIface.Network)