diff --git a/monitoredresource/monitored_resources.go b/monitoredresource/monitored_resources.go index 139f1c0..1a77508 100644 --- a/monitoredresource/monitored_resources.go +++ b/monitoredresource/monitored_resources.go @@ -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 } diff --git a/monitoredresource/monitored_resources_test.go b/monitoredresource/monitored_resources_test.go index 23d7238..d13e14b 100644 --- a/monitoredresource/monitored_resources_test.go +++ b/monitoredresource/monitored_resources_test.go @@ -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) } }