| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -61,6 +61,9 @@ | |||
| 61 | 61 | _GKE_CLUSTER_NAME = "instance/attributes/cluster-name" | |
| 62 | 62 | """Attribute in metadata server when in GKE environment.""" | |
| 63 | 63 | ||
| 64 | + _GKE_CLUSTER_LOCATION = "instance/attributes/cluster-location" | ||
| 65 | + """Attribute in metadata server when in GKE environment.""" | ||
| 66 | + | ||
| 64 | 67 | _PROJECT_NAME = "project/project-id" | |
| 65 | 68 | """Attribute in metadata server when in GKE environment.""" | |
| 66 | 69 | ||
@@ -94,15 +97,15 @@ def _create_kubernetes_resource(): | |||
| 94 | 97 | Returns: | |
| 95 | 98 | google.cloud.logging.Resource | |
| 96 | 99 | """ | |
| 97 | - zone = retrieve_metadata_server(_ZONE_ID) | ||
| 100 | + location = retrieve_metadata_server(_GKE_CLUSTER_LOCATION) | ||
| 98 | 101 | cluster_name = retrieve_metadata_server(_GKE_CLUSTER_NAME) | |
| 99 | 102 | project = retrieve_metadata_server(_PROJECT_NAME) | |
| 100 | 103 | ||
| 101 | 104 | resource = Resource( | |
| 102 | 105 | type="k8s_container", | |
| 103 | 106 | labels={ | |
| 104 | 107 | "project_id": project if project else "", | |
| 105 | - "location": zone if zone else "", | ||
| 108 | + "location": location if location else "", | ||
| 106 | 109 | "cluster_name": cluster_name if cluster_name else "", | |
| 107 | 110 | }, | |
| 108 | 111 | ) | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -56,6 +56,7 @@ def _mock_metadata(self, endpoint): | |||
| 56 | 56 | if ( | |
| 57 | 57 | endpoint == _monitored_resources._ZONE_ID | |
| 58 | 58 | or endpoint == _monitored_resources._REGION_ID | |
| 59 | + or endpoint == _monitored_resources._GKE_CLUSTER_LOCATION | ||
| 59 | 60 | ): | |
| 60 | 61 | return self.LOCATION | |
| 61 | 62 | elif ( | |
| Back | FazBrowse Home | New Git URL |
0 commit comments