Skip to content

Add GCE support - #2255

Open
jefchien wants to merge 2 commits into
mainfrom
gce-support
Open

Add GCE support#2255
jefchien wants to merge 2 commits into
mainfrom
gce-support

Conversation

@jefchien

Copy link
Copy Markdown
Contributor

Description of changes

Depends on amazon-contributing/opentelemetry-collector-contrib#634 (will need to update go.mod once merged)

Adds GCE (Google Compute Engine) as a host mode to the agent translator with a corresponding detector. The detector uses cloud.google.com/go/compute/metadata (which is already brought in as a transitive dependency by the resourcedetection processor and promoted to a direct dependency). When detected, the mode is set to ModeGCE which branches the translator in a couple ways:

  • The resourcedetection processor is set up with detectors: [env, gcp] so telemetry is enriched with GCP related attributes.
  • A new version of the identity transform processor is used (transform_identity_gce.yaml), which sets the cloud.resource_id resource attribute to the derived GCP Full Resource Name (https://docs.cloud.google.com/iam/docs/full-resource-names): //compute.googleapis.com/projects/{cloud.account.id}/zones/{cloud.availability_zone}/instances/{host.name} (Note: The page says the last part is INSTANCE_ID, but confirmed by looking at the Asset Inventory resource information that the last part is the VM display/host name)
  • Sets the provider to gcp for the oidctoken extension to support authentication.

License

By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice.

Tests

  • Added unit tests and a sample config for the default:otel config on GCE.
  • Built and tested on a GCE instance with mode set to auto.
    • Mode was auto-detected as GCE (after attempting to reach EC2 IMDS)
    • The oidctoken extension fetched and wrote the token to the expected file
    • Host metrics reached CloudWatch with the expected resource attributes
Resource Attribute Value
cloud.provider gcp
cloud.platform gcp_compute_engine
cloud.region us-east1
cloud.availability_zone us-east1-b
cloud.account.id {{project-id}}
cloud.resource_id //compute.googleapis.com/projects/{{project-id}}/zones/us-east1-b/instances/cwagent-otel-gce
host.type projects/{{project-number}}/machineTypes/e2-medium
host.name cwagent-otel-gce
host.id {{instance-id}}
deployment.environment.name gcp_compute_engine:{{project-id}}
image

Requirements

Before commiting your code, please do the following steps.

  1. Run make fmt and make fmt-sh
  2. Run make lint

Integration Tests

To run integration tests against this PR, add the ready for testing label.

@jefchien jefchien added the ready for testing Indicates this PR is ready for integration tests to run label Aug 26, 2026
@jefchien
jefchien marked this pull request as ready for review August 26, 2026 00:09
@jefchien
jefchien requested a review from a team as a code owner August 26, 2026 00:09
@github-actions

Copy link
Copy Markdown
Contributor

Binary Size Report

linux/amd64

Binary PR vs main (660543b) vs v1.300072.0
amazon-cloudwatch-agent 194.8 MB ${\color{red}▲}$ +12.3 KB (+0.0%) ${\color{red}▲}$ +1.5 MB (+0.8%)
amazon-cloudwatch-agent-config-wizard 2.0 MB +0 B +0 B
config-downloader 2.0 MB +0 B +0 B
config-translator 2.0 MB +0 B +0 B
start-amazon-cloudwatch-agent 2.5 MB +0 B +0 B
workload-discovery 3.0 MB +0 B +0 B
Total 206.4 MB ${\color{red}▲}$ +12.3 KB (+0.0%) ${\color{red}▲}$ +1.5 MB (+0.7%)
linux/amd64 amazon-cloudwatch-agent (last 9 main commits + this PR)

 195 ┤                                        
     ┤                    ▄▄▄ ▄▄▄ ███ ███ ███ 
     ┤                    ███ ███ ███ ███ ███ 
     ┤                    ███ ███ ███ ███ ███ 
     ┤                    ███ ███ ███ ███ ███ 
     ┤                    ███ ███ ███ ███ ███ 
     ┤                    ███ ███ ███ ███ ███ 
     ┤                    ███ ███ ███ ███ ███ 
 193 ┤▄▄▄ ▄▄▄ ▄▄▄ ▄▄▄ ▄▄▄ ███ ███ ███ ███ ███ 
 MB  └────────────────────────────────────────
      ca8av1.300072.0                     PR

Notable changes:

linux/arm64
Binary PR vs main (660543b) vs v1.300072.0
amazon-cloudwatch-agent 178.6 MB +0 B ${\color{red}▲}$ +1.5 MB (+0.9%)
amazon-cloudwatch-agent-config-wizard 2.0 MB +0 B +0 B
config-downloader 2.0 MB +0 B +0 B
config-translator 2.0 MB +0 B +0 B
start-amazon-cloudwatch-agent 2.4 MB +0 B +0 B
workload-discovery 2.9 MB +0 B +0 B
Total 189.9 MB +0 B ${\color{red}▲}$ +1.5 MB (+0.8%)
windows/amd64
Binary PR vs main (660543b) vs v1.300072.0
amazon-cloudwatch-agent.exe 197.6 MB ${\color{red}▲}$ +18.4 KB (+0.0%) ${\color{red}▲}$ +1.5 MB (+0.8%)
amazon-cloudwatch-agent-config-wizard.exe 2.1 MB +0 B +0 B
config-downloader.exe 2.1 MB +0 B +0 B
config-translator.exe 2.1 MB +0 B +0 B
start-amazon-cloudwatch-agent.exe 2.3 MB +0 B +0 B
workload-discovery.exe 2.9 MB +0 B ${\color{red}▲}$ +512 B (+0.0%)
Total 209.3 MB ${\color{red}▲}$ +18.4 KB (+0.0%) ${\color{red}▲}$ +1.5 MB (+0.7%)
Investigating size changes

Use go-size-analyzer to compare binaries:

GOEXPERIMENT=jsonv2 go install github.com/Zxilly/go-size-analyzer/cmd/gsa@latest
gsa diff --old <baseline-binary> --new <new-binary>

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

ready for testing Indicates this PR is ready for integration tests to run

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants