Skip to content
This repository has been archived by the owner on Oct 3, 2023. It is now read-only.

Commit

Permalink
Fix k8s_container resource labels. (#93)
Browse files Browse the repository at this point in the history
* Fix k8s_container resource labels.

* Also fix location label.

* Small fix
  • Loading branch information
songy23 authored Feb 28, 2019
1 parent 14131f5 commit aaad73f
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 7 deletions.
13 changes: 9 additions & 4 deletions monitoredresource/monitored_resources.go
Original file line number Diff line number Diff line change
Expand Up @@ -62,15 +62,20 @@ func (gke *GKEContainer) MonitoredResource() (resType string, labels map[string]
labels = map[string]string{
"project_id": gke.ProjectID,
"instance_id": gke.InstanceID,
"zone": gke.Zone,
"cluster_name": gke.ClusterName,
"container_name": gke.ContainerName,
"namespace_id": gke.NamespaceID,
"pod_id": gke.PodID,
}
typ := "gke_container"
var typ string
if gke.LoggingMonitoringV2Enabled {
typ = "k8s_container"
labels["pod_name"] = gke.PodID
labels["namespace_name"] = gke.NamespaceID
labels["location"] = gke.Zone
} else {
typ = "gke_container"
labels["pod_id"] = gke.PodID
labels["namespace_id"] = gke.NamespaceID
labels["zone"] = gke.Zone
}
return typ, labels
}
Expand Down
6 changes: 3 additions & 3 deletions monitoredresource/monitored_resources_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -81,9 +81,9 @@ func TestGKEContainerMonitoredResourcesV2(t *testing.T) {
labels["project_id"] != GCPProjectIDStr ||
labels["cluster_name"] != GKEClusterNameStr ||
labels["container_name"] != GKEContainerNameStr ||
labels["zone"] != GCPZoneStr ||
labels["namespace_id"] != GKENamespaceStr ||
labels["pod_id"] != GKEPodIDStr {
labels["location"] != GCPZoneStr ||
labels["namespace_name"] != GKENamespaceStr ||
labels["pod_name"] != GKEPodIDStr {
t.Errorf("GKEContainerMonitoredResourceV2 Failed: %v", autoDetected)
}
}
Expand Down

0 comments on commit aaad73f

Please sign in to comment.