Skip to content

Commit 21964a6

Browse files
authored
Change 'metadata.cloud.project.*' for GCP, clarify other fields (#822)
1 parent 5791498 commit 21964a6

File tree

1 file changed

+10
-5
lines changed

1 file changed

+10
-5
lines changed

specs/agents/metadata.md

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -247,7 +247,7 @@ From the returned metadata, the following fields are useful
247247
#### GCP metadata
248248

249249
Metadata about a GCP machine instance can be retrieved from the
250-
metadata service, `http://metadata.google.internal`.
250+
metadata service, [documented here](https://cloud.google.com/compute/docs/metadata/default-metadata-values).
251251

252252
In the case where a proxy is configured on the application, the agents SHOULD attempt to make
253253
the calls to the metadata endpoint directly, without using the proxy.
@@ -265,14 +265,19 @@ From the returned metadata, the following fields are useful
265265

266266
| Cloud metadata field | GCP Metadata field |
267267
| -------------------- | ------------------- |
268-
| `instance.id` | `instance.id` |
268+
| `instance.id` | `instance.id` as a string [1] |
269269
| `instance.name` | `instance.name` |
270-
| `project.id` | `project.numericProjectId` as a string |
271-
| `project.name` | `project.projectId` |
270+
| `project.id` | `project.projectId` [2] |
272271
| `availability_zone` | last part of `instance.zone`, split by `/` |
273272
| `machine.type` | last part of `instance.machineType`, split by `/` |
274273
| `provider` | gcp |
275-
| `region` | last part of `instance.zone`, split by `-` |
274+
| `region` | last part of `instance.zone` split by '/', then remove the last '-'-delimited part (e.g., `us-west1` from `projects/123456789012/zones/us-west1-b`)|
275+
276+
[1]: Beware JSON parsing the `instance.id` field from the HTTP response body, because it is formatted as an integer that is larger [JavaScript's `Number.MAX_SAFE_INTEGER`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Number/MAX_SAFE_INTEGER). It may require native support for or explicit usage of BigInt types.
277+
[2]: Google cloud project identifiers are [described here](https://cloud.google.com/resource-manager/docs/creating-managing-projects#before_you_begin).
278+
279+
(For comparison and consistency, here is the equivalent collection code for
280+
[beats](https://github.com/elastic/beats/blob/aa5da2847957fa62687e0b4e7777c86fe7c05f6c/libbeat/processors/add_cloud_metadata/provider_google_gce.go#L45-L153).)
276281

277282
#### Azure metadata
278283

0 commit comments

Comments
 (0)