When deploying hybrid environments, standardizing telemetry collection helps maintain operational insights without exposing sensitive data. Organizations use open-source frameworks like the OpenTelemetry Collector or Fluentd to gather distributed metrics and logs. A key practice is separating sensitive application data from system operations data, allowing teams to route lower-risk operational telemetry to Google Cloud while keeping sensitive details on-premises. This hybrid setup ensures robust telemetry coverage across virtual machines and containers while satisfying strict security boundaries.
To build enterprise-grade routing architectures, DevOps engineers configure Log Router sinks to direct platform and network telemetry to strategic destinations. Specific log filters can be configured to capture valuable network-related fields like IP addresses, ports, and security actions. Common destination targets include Cloud Storage for low-cost, long-term retention, BigQuery for advanced SQL analytical queries, and Pub/Sub for real-time, asynchronous integration with third-party tools.
Managing log volume is critical for controlling ingestion costs and ensuring high-performance monitoring. Engineers write exclusion filters in the Logging query language to drop repetitive or low-priority log entries before they are permanently stored in log buckets. It is important to know that excluded logs still consume API write quotas because filters evaluate logs after they reach the Logging API. This technique allows teams to prioritize high-value debugging information, such as microservices communication logs, while filtering out noisy telemetry.
For compliance and troubleshooting, organizations can customize log storage settings, define custom retention periods, and restrict access. Engineers can implement customer-managed encryption keys (CMEK) to secure logs at rest and configure regional storage to meet strict data residency requirements. Additionally, previously exported logs can be imported back into Cloud Logging using Cloud Run jobs, provided they fit within the 30-day retention period. Enabling detailed Data Access audit logs provides Google Support with the necessary telemetry to troubleshoot account-level issues effectively.
The Ops Agent is the primary, unified agent for collecting logs, metrics, and traces from Compute Engine instances. It consolidates telemetry collection into a single process by using Fluent Bit for high-throughput logging and the OpenTelemetry Collector for metrics and traces. This agent replaces the legacy Logging and Monitoring agents and is configured through a unified config.yaml file that manages receivers, processors, and pipelines. It supports multiple Linux and Windows operating systems, providing native features like proxy support, structured log parsing, and curated integrations.
To collect application-level telemetry like custom metrics and traces, you integrate the OpenTelemetry Protocol (OTLP). Applications instrumented with OpenTelemetry SDKs send OTLP data directly to the Ops Agent's OTLP receiver, which listens for gRPC traffic on port 4317. This approach decouples application instrumentation from Google Cloud credentials and protects against data loss during application crashes by buffering data at the agent level. You can configure the agent to ingest OTLP metrics as Prometheus-formatted metrics or as native Cloud Monitoring custom metrics.
Customizing telemetry collection involves defining specific pipelines within the config.yaml file. For logs, you configure receivers for system logs, journald, or custom log files, and apply processors to parse JSON, use regular expressions, modify fields, or exclude logs. For metrics, you enable receivers for Prometheus endpoints or OTLP and route them through dedicated pipelines. The agent also provides a Metrics Management page in Cloud Monitoring to view ingestion volumes and exclude unneeded metrics to control costs.
For advanced, centralized collection scenarios, such as in Kubernetes or on Container-Optimized OS, you can deploy the standalone Google-Built OpenTelemetry Collector. This collector offers a broader set of components and can be configured with exporters, processors like batch and memory_limiter, and receivers to route telemetry to multiple backends. Ultimately, configuring the Ops Agent with OpenTelemetry standardizes telemetry collection across hosts and applications, ensuring comprehensive data capture for troubleshooting.
Cloud Audit Logs automatically record administrative actions and data access patterns across Google Cloud resources to establish a complete audit trail. Admin Activity logs capture operations that modify resource configurations, while Data Access logs track read and write operations on data. Additionally, System Event logs record Google Cloud system events, and Policy Denied logs document when access is blocked by security policies. This structured log data helps organizations maintain visibility for compliance, security, and troubleshooting.
Engineers use the Logs Explorer or the gcloud command-line tool to query structured audit logs by specifying the resource type, log name, and relevant event filters. For example, to view Admin Activity logs, you would select "activity" as the log name type. The structured logs capture who performed the action, when it occurred, and which resources were affected. Organizations can route these logs to Cloud Storage, BigQuery, or Pub/Sub for extended retention and advanced analysis.
VPC Flow Logs capture information about the network traffic flowing through your Virtual Private Cloud network. These logs are essential for diagnosing network latency, tracing connectivity issues between services, and monitoring network security boundaries. Flow logs record metadata such as source and destination IP addresses, ports, protocols, and the volume of data transmitted. Network administrators analyze this data to identify unusual traffic patterns, troubleshoot connection failures, and verify that firewall rules are working correctly.
Google Cloud offers multiple approaches for log collection depending on the environment and requirements. The Ops Agent is the recommended solution as it uses stable open-source technologies like Fluent Bit and the OpenTelemetry Collector. Other options include the legacy Logging agent, stdout/stderr redirection to Cloud Logging, and client libraries for direct application logging. Organizations combine these logs with log-based metrics and log-based alerting policies to trigger notifications for critical events, such as security breaches or configuration changes.
Professional Cloud DevOps Engineer
Gauge your current knowledge
Gauge your current knowledge