Google Cloud Logging
Synopsis
The Google Cloud Logging target forwards events to Google Cloud Logging (formerly Stackdriver Logging) with configurable severity levels, labels, and authentication methods.
Schema
- name: <string>
description: <string>
type: gcplogging
pipelines: <pipeline[]>
status: <boolean>
properties:
project_id: <string>
log_name: <string>
authentication:
method: <auto|manual|secret>
credentials: <string>
severity: <string>
labels: <map>
batch_size: <integer>
timeout: <integer>
max_retries: <integer>
retry_delay: <integer>
field_format: <string>
debug:
status: <boolean>
dont_send_logs: <boolean>
Configuration
The following fields are used to define the target:
| Field | Required | Default | Description |
|---|---|---|---|
name | Y | Target name | |
description | N | - | Optional description |
type | Y | Must be gcplogging | |
pipelines | N | - | Optional post-processor pipelines |
status | N | true | Enable/disable the target |
Connection
| Field | Required | Default | Description |
|---|---|---|---|
project_id | Y | - | Google Cloud project ID |
log_name | Y | - | Log name within the project |
Authentication
| Field | Required | Default | Description |
|---|---|---|---|
authentication.method | N | auto | Authentication method: auto, manual, secret |
credentials | N* | - | JSON service account credentials (inline string or environment variable expansion) |
* = Conditionally required when authentication.method is manual or secret.
Log Settings
| Field | Required | Default | Description |
|---|---|---|---|
severity | N | DEFAULT | Default log severity level. See Severity Levels below |
labels | N | - | Map of custom labels to attach to all log entries |
Batch Configuration
| Field | Required | Default | Description |
|---|---|---|---|
batch_size | N | 1000 | Maximum log entries per batch |
timeout | N | 30 | Request timeout in seconds |
max_retries | N | 0 | Maximum retry attempts for failed sends (0 = no retries) |
retry_delay | N | 1 | Delay between retries in seconds |
Processing
| Field | Required | Default | Description |
|---|---|---|---|
field_format | N | - | Data normalization format. See applicable Normalization section |
Scheduling
See Scheduling and Pool Behavior for interval and cron fields shared by all targets.
Debug Options
| Field | Required | Default | Description |
|---|---|---|---|
debug.status | N | false | Enable debug logging |
debug.dont_send_logs | N | false | Process logs but don't send to target (testing) |
Details
Severity Levels
Valid severity levels for Google Cloud Logging:
| Severity | Description |
|---|---|
DEFAULT | Default severity (no specific level) |
DEBUG | Debug or trace information |
INFO | Informational messages |
NOTICE | Normal but significant events |
WARNING | Warning events |
ERROR | Error events |
CRITICAL | Critical events requiring immediate action |
ALERT | Alert requiring immediate notification |
EMERGENCY | Emergency requiring immediate response |
Authentication Methods
Auto (Default):
- Uses Application Default Credentials (ADC)
- Checks
GOOGLE_APPLICATION_CREDENTIALSenvironment variable - Falls back to compute metadata service for GCE/GKE
Manual:
- Inline JSON service account credentials
- Credentials embedded directly in configuration
Secret:
- Service account credentials from environment variable
- More secure than inline credentials for production
IAM Permissions
The service account requires the following IAM role:
| IAM Role | Role ID | Purpose |
|---|---|---|
Logs Writer | roles/logging.logWriter | Write log entries to Cloud Logging |
Minimum permissions: logging.logEntries.create
Log Entry Structure
Each log entry sent to Google Cloud Logging includes:
- Timestamp: Event timestamp from pipeline
- Severity: Configured or default severity level
- Payload: Event message content
- Labels: Custom labels for filtering and organization
Labels for Log Organization
Labels enable efficient log filtering and organization:
- Resource labels: Identify the source resource
- User labels: Custom categorization
- System labels: Automatic GCP-assigned labels
Labels are key-value pairs attached to every log entry.
Performance Considerations
Batch Processing:
- Events are buffered until
batch_sizeis reached - Flush occurs on batch limit or service shutdown
- Larger batches reduce API calls but increase latency
Retry Logic:
- Failed sends are retried up to
max_retriestimes - Exponential backoff between retries using
retry_delay - Permanent failures are logged but not re-queued
Examples
Basic Configuration
Sending logs to Google Cloud Logging using auto authentication from Application Default Credentials... | |
With Service Account
Using explicit service account credentials for authentication... | |
With Secret Authentication
Loading service account credentials from environment variable for better security... | |
With Severity and Labels
Configuring specific severity level and custom labels for log organization... | |
High-Volume Configuration
Optimizing for high-volume log ingestion with larger batches and retry configuration... | |
Error Severity
Forwarding error logs with ERROR severity for immediate visibility... | |
Debug Logs
Sending debug-level logs for development and troubleshooting... | |
Production Configuration
Production-ready configuration with performance tuning, retry logic, and comprehensive labels... | |