This document describes how to configure the Ops Agent to use the
Telemetry (OTLP) API,
telemetry.googleapis.com. The Telemetry API is an implementation of
the open-source OpenTelemetry Line Protocol. When you enable this feature,
the Ops Agent sends both logs and metrics to your Google Cloud project by using the
Telemetry API rather than the proprietary Cloud Monitoring API and
Cloud Logging API.
If you adopt the use of the Telemetry API in the Ops Agent and
have charts or alerting policies that monitor your API usage, then you
must update these artifacts to monitor the telemetry.googleapis.com endpoint
rather than the monitoring.googleapis.com or logging.googleapis.com endpoints.
Before you begin
To use the Telemetry API, do the following:
Enable the Telemetry API in your Google Cloud project, if it is not already enabled. You can enable the API by running the following command:
gcloud services enable
telemetry.googleapis.comAdjust Telemetry API quotas, if the default values are not sufficient. The Telemetry API has quotas separate from those of the Cloud Monitoring API and Cloud Logging API. For information about the quotas and limits for the Telemetry API, see the following:
You might need to adjust these quotas to accommodate the volume of telemetry data you ingest.
Configure the Ops Agent to use the Telemetry API
During the Preview period, use of the Telemetry API by the Ops Agent
is controlled by an environment variable, EXPERIMENTAL_FEATURES.
To collect telemetry by using the Ops Agent and the Telemetry API,
you must do the following, as described in the following sections:
- Install a version of the Ops Agent that supports the Telemetry API.
- Set the
EXPERIMENTAL_FEATURESenvironment variable. - Restart the Ops Agent to pick up the change.
Use Ops Agent version 2.66.0 or newer
To use the Telemetry API with the Ops Agent, you must install the Ops Agent version 2.66.0 or newer. For information about installing the Ops Agent, see Install the Ops Agent of individual VMs.
Set the environment variable
Give the Ops Agent access to the Telemetry API by setting the
EXPERIMENTAL_FEATURES environment variable to the value
otlp_exporter, as shown in the following tabs:
Linux
To modify the environment for the Ops Agent, run the following commands on your instance:
for service in \
google-cloud-ops-agent \
google-cloud-ops-agent-fluent-bit \
google-cloud-ops-agent-opentelemetry-collector \
; do
sudo mkdir -p "/etc/systemd/system/${service}.service.d"
echo -e '[Service]\nEnvironment="EXPERIMENTAL_FEATURES=otlp_exporter"' | sudo tee "/etc/systemd/system/${service}.service.d/otlp_exporter.conf"
done
sudo systemctl daemon-reload
Windows
To modify the environment for the Ops Agent, perform the following steps:
- Connect to your instance using RDP or a similar tool and login to Windows.
- Open a PowerShell terminal with administrator privileges by right-clicking the PowerShell icon and selecting Run as Administrator
- Set the
EXPERIMENTAL_FEATURESenvironment variable by running the following PowerShell command:setx EXPERIMENTAL_FEATURES "otlp_exporter" /M
Restart the Ops Agent
Linux
- To restart the agent, run the following command on your instance:
sudo systemctl restart google-cloud-ops-agent
- To confirm that the agent restarted, run the following command and
verify that the components "Metrics Agent" and "Logging Agent" started:
sudo systemctl status "google-cloud-ops-agent*"
Windows
- Connect to your instance using RDP or a similar tool and login to Windows.
- Open a PowerShell terminal with administrator privileges by right-clicking the PowerShell icon and selecting Run as Administrator
- To restart the agent, run the following PowerShell command:
Restart-Service google-cloud-ops-agent -Force
- To confirm that the agent restarted, run the following command and
verify that the components "Metrics Agent" and "Logging Agent" started:
Get-Service google-cloud-ops-agent*
Configure the Ops Agent to not use the Telemetry API
To stop the Ops Agent from collecting telemetry by using the Telemetry API and to resume collecting telemetry by using the Cloud Monitoring API and the Cloud Logging API, you must do the following:
Unset the
EXPERIMENTAL_FEATURESenvironment variable.Linux
To modify the environment for the Ops Agent, run the following commands on your instance:
sudo find /etc/systemd/system -name otlp_exporter.conf | sudo xargs rm sudo systemctl daemon-reload
Windows
To modify the environment for the Ops Agent, perform the following steps:
- Connect to your instance using RDP or a similar tool and login to Windows.
- Open a PowerShell terminal with administrator privileges by right-clicking the PowerShell icon and selecting Run as Administrator
- Remove the
EXPERIMENTAL_FEATURESenvironment variable by running the following PowerShell command:REG delete "HKLM\SYSTEM\CurrentControlSet\Control\Session Manager\Environment" /F /V EXPERIMENTAL_FEATURES
Restart the Ops Agent to pick up the change.
What's next
- To learn more about the Telemetry API, see Telemetry (OTLP) API overview.
- For information about installing and configuring the Ops Agent, see the following documents: