# File

### 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.

<figure><img src="/files/KpEcOFSBvc7DlVUJpNFK" alt="Basic File destination configuration with File Path set to /var/log/telemetry.log and default settings"><figcaption></figcaption></figure>

| 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 settings](https://docs.bindplane.com/configuration/bindplane-otel-collector/retry-on-failure), the [sending queue settings](https://docs.bindplane.com/configuration/bindplane-otel-collector/sending-queue), and the [persistent queue settings](https://docs.bindplane.com/configuration/bindplane-otel-collector/persistent-queue).

### Examples

#### JSON with File Rotation

<figure><img src="/files/jqz4LEMvLBqPkQMiy2XX" alt="File destination with max file size of 50 MB and 10 backups enabled"><figcaption></figcaption></figure>

#### Protocol Buffers with Compression

<figure><img src="/files/sx1Bk4M6idAqBkZVDo0K" alt="File destination using proto format with zstd compression"><figcaption></figcaption></figure>

#### Resource Attribute Grouping

<figure><img src="/files/FwOmZKEFaQ5R4tUkvTDr" alt="File destination with grouping enabled by service.name attribute"><figcaption></figcaption></figure>

### 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

### Related Resources

* [File Exporter Documentation](https://github.com/open-telemetry/opentelemetry-collector-contrib/tree/main/exporter/fileexporter)
* [Bindplane Destinations Overview](https://docs.bindplane.com/resources/destinations/)
* [Retention and Queuing Configuration](https://docs.bindplane.com/configuration/bindplane-otel-collector/retry-and-queueing)


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.bindplane.com/integrations/destinations/file.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
