File

Write telemetry data to files on the local filesystem. Supports automatic file rotation, compression, and grouping by resource attributes for organized log management.

Supported Telemetry Types

Logs
Metrics
Traces

Prerequisites

Before configuring the File destination, ensure you have:

  • Write access to the target directory path

  • Sufficient disk space for telemetry data

  • Appropriate file system permissions for the collector process

  • For directory creation: permissions to create parent directories

Configuration

Basic Configuration

The minimum configuration requires only the file path. The destination will write telemetry data in JSON format by default.

Basic File destination configuration with File Path set to /var/log/telemetry.log and default settings
Parameter
Type
Required
Default
Description

Choose Telemetry Type

Telemetry Selector

No

Logs, Metrics, Traces

Types of telemetry to export

File Path

String

Yes

Path to the file for telemetry output

Advanced Configuration

File Format and Compression

Parameter
Type
Default
Description

Format

Enum (json, proto)

json

Output format for telemetry data

Compression

Enum (none, zstd)

none

Compression algorithm for output

File Rotation Settings

Parameter
Type
Default
Description

Rotation - Max File Size (MB)

Integer

100

Max file size before rotation (0 = disabled)

Rotation - Max Days

Integer

0

Days to retain files (0 = unlimited)

Rotation - Max Backups

Integer

100

Number of old files to keep (0 = unlimited)

Rotation - Use Local Time

Boolean

false

Use local time for rotation timestamps instead of UTC

Write and Directory Settings

Parameter
Type
Default
Description

Flush Interval (seconds)

Integer

1

Seconds between buffer flushes (ignored when rotation enabled)

Append Mode

Boolean

false

Append to file instead of truncating

Create Directory

Boolean

false

Create directory path if it doesn't exist

Directory Permissions (Octal)

String

0755

Permissions for created directories

Resource-Based File Grouping

Parameter
Type
Default
Description

Group by Resource Attribute

Boolean

false

Write to separate files based on resource attributes

Resource Attribute Name

String

fileexporter.path_segment

Attribute name for grouping (when grouping enabled)

Group by - Max Open Files

Integer

100

Max file descriptors when grouping (when grouping enabled)

Log Processing

Parameter
Type
Default
Description

Drop Raw Copy

Boolean

true

Remove log.record.original attribute from logs

Retry and Queuing

This destination supports the retry settingsarrow-up-right, the sending queue settingsarrow-up-right, and the persistent queue settingsarrow-up-right.

Examples

JSON with File Rotation

File destination with max file size of 50 MB and 10 backups enabled

Protocol Buffers with Compression

File destination using proto format with zstd compression

Resource Attribute Grouping

File destination with grouping enabled by service.name attribute

Configuration Tips

File Path and Permissions

  • Specify absolute paths to avoid ambiguity (e.g., /var/log/telemetry.log instead of logs/telemetry.log)

  • Ensure the collector process has write permissions to the target directory

  • Use Create Directory to automatically set up directory structure with specified permissions

  • For Kubernetes, use persistent volumes to prevent data loss on pod restart

File Rotation Strategy

  • Enable rotation for long-running collectors to prevent unbounded file growth

  • Set Max File Size based on disk capacity and log volume (100 MB default is reasonable for most workloads)

  • Use Max Days to implement retention policies, or disable (0) for indefinite retention

  • Set Max Backups to control storage usage; old files are automatically deleted when limit is exceeded

Format Selection

  • JSON: Human-readable, easier to debug, slightly larger file size

  • Proto: Compact binary format, ~50% smaller files, requires decoder to inspect

Troubleshooting

Permission Denied Errors

Symptoms: "permission denied" errors when writing to file or creating directory.

Solutions:

  1. Verify the collector process user has write permissions to the target directory

  2. Check parent directory permissions if using Create Directory

  3. Verify directory permissions (octal format) are correct: 0755 allows owner read/write/execute

  4. Ensure SELinux or AppArmor policies don't restrict file access

File Rotation Not Working

Symptoms: Files grow indefinitely despite rotation settings, or rotation happens unexpectedly.

Solutions:

  1. Verify Max File Size is greater than 0 (0 disables rotation)

  2. Check available disk space; rotation may fail if disk is full

  3. Ensure write permissions exist for directory where rotated files are created

  4. Verify Flush Interval is configured when grouping is disabled (rotation ignored otherwise)

Missing Data in Files

Symptoms: Some telemetry appears to be lost or not written to file.

Solutions:

  1. Verify the source is actually generating telemetry

  2. Check collector logs for errors related to the file exporter

  3. If using Group by Resource Attribute: verify the attribute exists on all telemetry items

  4. If grouping is enabled with high cardinality attributes: check that max open files limit isn't exceeded

Last updated

Was this helpful?