Skip to main content

Googlecloudstorage Exporter

Status Available in: contrib Maintainers: @constanca-m, @braydonk Source: opentelemetry-collector-contrib

Supported Telemetry

Logs Traces

Overview

This exporter writes received OpenTelemetry data to a cloud storage bucket.

Configuration

NameDescriptionRequiredDefault
encodingThe encoding extension ID to use for marshaling logs and traces. If left empty, plog.JSONMarshaler will be used for logs and ptrace.JSONMarshaler will be used for traces.No
bucket.project_idThe project where the bucket will be created or where it exists. If left empty, it will query the metadata endpoint. It requires the collector to be running in a Google Cloud environment.No
bucket.nameName for the bucket storage.Yes
bucket.file_prefixPrefix for the created filename. This prefix is applied after the partition path (if any).Nologs
bucket.partitionConfiguration for time-based partitioning. See below for details.No
bucket.reuse_if_existsControls bucket creation behavior. If true, checks if bucket exists and uses it (requires storage.buckets.get permission on the bucket); fails if bucket doesn’t exist. If false, attempts to create bucket; fails if bucket already exists (requires storage.buckets.create permission at project level). Set to true when the service account lacks project-level bucket creation permissions but has bucket-level permissions.Nofalse
bucket.regionRegion where the bucket will be created or where it exists. If left empty, it will query the metadata endpoint. It requires the collector to be running in a Google Cloud environment.Yes
bucket.compressionCompression algorithm used to compress data before uploading. Valid values are gzip, zstd, or no value set for no compression.No

Partition Configuration

The bucket.partition configuration allows you to organize files into time-based folders.
NameDescriptionRequiredDefault
formatTime format string for time-based partitions. If set, formatted UTC time is prepended to the filename. Supports strftime format (e.g., year=%Y/month=%m).No
prefixPrefix for the partition folder structure. If set, this value is prepended to the partition path.No

Example

Here is an example configuration for this exporter:
exporters:
  google_cloud_storage:
    encoding: text_encoding
    bucket:
      name: bucket-test
      project_id: project-test
      reuse_if_exists: true
      region: europe-west1
      file_prefix: app-logs
      partition:
        prefix: archive
        format: "year=%Y/month=%m/day=%d/hour=%H"

extensions:
  # text encoding to ensure only the body is placed in the bucket
  text_encoding:

Compression Example

exporters:
  google_cloud_storage:
    bucket:
      name: compressed-logs-bucket
      project_id: my-project
      region: us-central1
      compression: gzip
      file_prefix: logs
      partition:
        format: "year=%Y/month=%m/day=%d"

Using with Bucket-Level Permissions Only

When the service account lacks project-level bucket creation permissions but has bucket-level permissions:
exporters:
  google_cloud_storage:
    bucket:
      name: existing-bucket
      project_id: my-project
      region: us-central1
      reuse_if_exists: true
      file_prefix: collector-logs
With reuse_if_exists: true, the exporter checks if the bucket exists using storage.buckets.get permission on that specific bucket (not project-level). If the bucket doesn’t exist, the exporter will fail with an error. This allows service accounts with only bucket-level permissions to work without requiring project-level bucket creation permissions.

Configuration

Example Configuration

google_cloud_storage:
  encoding: test
  bucket:
    region: test-region
    name: test-bucket
    project_id: test-project-id

google_cloud_storage/with_partition:
  encoding: test
  bucket:
    region: test-region
    name: test-bucket
    project_id: test-project-id
    partition:
      format: year=%Y
      prefix: my-logs

google_cloud_storage/empty_bucket_name:
  encoding: test
  bucket:
    region: test-region
    project_id: test-project-id

google_cloud_storage/invalid_partition_format:
  encoding: test
  bucket:
    region: test-region
    name: test-bucket
    project_id: test-project-id
    partition:
      format: year=%invalid

google_cloud_storage/with_gzip_compression:
  encoding: test
  bucket:
    region: test-region
    name: test-bucket
    project_id: test-project-id
    compression: gzip

google_cloud_storage/with_zstd_compression:
  encoding: test
  bucket:
    region: test-region
    name: test-bucket
    project_id: test-project-id
    compression: zstd

google_cloud_storage/unsupported_compression:
  encoding: test
  bucket:
    region: test-region
    name: test-bucket
    project_id: test-project-id
    compression: snappy

Last generated: 2026-04-13