Google Compute Engine (GCE)
Monitor Google Compute Engine instances with system metrics and logs using OpenTelemetry collector with Last9
Use Last9’s OpenTelemetry endpoint to ingest logs and host metrics from GCE instances using Otel Collector.
Prerequisites
Before setting up Google Compute Engine monitoring, ensure you have:
- Google Compute Engine instances running
- Administrative access to your GCE instances
- OpenTelemetry Collector installation access
- Last9 account with integration credentials
-
Install OpenTelemetry Collector
There are multiple ways to install the Otel Collector. Every Collector release includes APK, DEB and RPM packaging for Linux amd64/arm64/i386 systems.
Note: systemd is required for automatic service configuration.
Installing rpm package:
wget https://github.com/open-telemetry/opentelemetry-collector-releases/releases/download/v0.118.0/otelcol-contrib_0.118.0_linux_amd64.rpmsudo rpm -ivh otelcol-contrib_0.118.0_linux_amd64.rpmInstalling deb package:
wget https://github.com/open-telemetry/opentelemetry-collector-releases/releases/download/v0.118.0/otelcol-contrib_0.118.0_linux_amd64.debsudo dpkg -i otelcol-contrib_0.118.0_linux_amd64.debMore installation options can be found here.
Note: We recommend installing
otel-collector-contribversion0.118.0. -
Configure OpenTelemetry Collector
The default path for otel config is
/etc/otelcol-contrib/config.yaml.You can edit it and update it with below configuration. The configuration is annotated with comments which should be addressed before applying the configuration.
The configuration provides sample examples of both JSON and regex parsers.
receivers:hostmetrics:collection_interval: 60sscrapers:cpu:metrics:system.cpu.logical.count:enabled: truememory:metrics:system.memory.utilization:enabled: truesystem.memory.limit:enabled: trueload:disk:filesystem:metrics:system.filesystem.utilization:enabled: truenetwork:paging:processes:process:mute_process_user_error: truemute_process_io_error: truemute_process_exe_error: truemetrics:process.cpu.utilization:enabled: trueprocess.memory.utilization:enabled: trueprocess.threads:enabled: trueprocess.paging.faults:enabled: trueotlp:protocols:grpc:endpoint: 0.0.0.0:4317http:endpoint: 0.0.0.0:4318# Detailed configuration options can be found at https://github.com/open-telemetry/opentelemetry-collector-contrib/tree/main/receiver/filelogreceiverfilelog:# File path pattern to read logs from. Update this to the destination from where you want to read logs.include: [/tmp/*.log]include_file_path: true# attributes:# A map of key: value pairs to add to the entry's attributes.# resource:# A map of key: value pairs to add to the entry's resource.retry_on_failure:enabled: trueprocessors:batch:timeout: 20ssend_batch_size: 100000send_batch_max_size: 100000resourcedetection/gcp:detectors: ["gcp"]transform/logs:error_mode: ignorelog_statements:- context: resourcestatements:- set(attributes["service.name"], "my-service") # Change this to your service nameresourcedetection/system:detectors: ["system"]system:hostname_sources: ["os"]exporters:debug:verbosity: detailedotlp/last9:endpoint: "{{ .Logs.WriteURL }}"headers:"Authorization": "{{ .Logs.AuthValue }}"service:pipelines:logs:receivers: [filelog]processors: [resourcedetection/gcp, transform/logs, batch]exporters: [otlp/last9]metrics:receivers: [hostmetrics]processors: [resourcedetection/system, batch]exporters: [otlp/last9] -
Start OpenTelemetry Collector
Run the otel collector using
systemctlcommand:sudo systemctl start otelcol-contribsudo systemctl status otelcol-contribsudo systemctl restart otelcol-contrib -
Check Collector Logs
Monitor the collector logs to ensure it’s working correctly:
sudo journalctl -u otelcol-contrib -f
Verification
To verify the setup is working:
- Check that the collector service is running
- Review the collector logs for any errors
- Log into your Last9 account to confirm GCE metrics and logs are being received
Need Help?
If you encounter any issues or have questions:
- Join our Discord community for real-time support
- Contact our support team at support@last9.io