Skip to main content

File

Long Term Storage

Synopsis

Creates a file target that writes log messages to files in various formats like JSON, Avro, OCF, Parquet, with support for various compression methods and schemas.

Schema

- id: <numeric>
name: <string>
description: <string>
type: file
pipelines: <pipeline[]>
status: <boolean>
properties:
location: <string>
name: <string>
type: <string>
compression: <string>
schema: <string>
format: <string>
no_buffer: <boolean>

Configuration

The following are the minimum requirements to define the target.

FieldRequiredDefaultDescription
idYUnique identifier
nameYTarget name
descriptionN-Optional description
typeYMust be file
pipelinesN-Optional post-processor pipelines
statusNtrueEnable/disable the target

Files

FieldRequiredDefaultDescription
locationN<service-root>File output directory
nameN"vmetric.{{.Timestamp}}.{{.Extension}}"File name template
typeN"json"File format: json, avro, ocf, or parquet
compressionN"zstd"Compression algorithm
schemaN-Data schema for Avro/OCF/Parquet formats
no_bufferNfalseDisable write buffering
formatN-Field normalization format: ecs, cim, or asim

Details

If no schema is specified the for the Avro, OCF, or Parquet formats, a default schema will be used that captures epoch timestamp and message content.

note

Files with no messages (i.e. with counter=0) are automatically removed when the target is disposed.

Templates

The following template variables can be used in the file name:

VariableDescriptionExample
{{.Year}}Current year2024
{{.Month}}Current month01
{{.Day}}Current day15
{{.Timestamp}}Current timestamp in nanoseconds1703688533123456789
{{.Type}}File typejson
{{.Extension}}File extensionjson
{{.Compression}}Compression typezstd
{{.TargetName}}Target namemy_logs
{{.TargetType}}Target typefile

Compression

FormatCompression
JSONzstd
AvroNone
OCFnull, deflate, snappy, zstd
Parquetuncompressed, gzip, snappy, zstd, brotli, lz4

Examples

JSON

The minimum configuration for JSON file output:

- id: 1
name: json_logs
type: file
properties:
location: "/var/log/vmetric"

Parquet

Configuration for Parquet output with compression and schema:

- id: 2
name: parquet_logs
type: file
properties:
location: "/var/log/vmetric"
type: "parquet"
compression: "zstd"
schema: |
{
"timestamp": {
"type": "INT",
"bitWidth": 64,
"signed": true
},
"message": {
"type": "STRING",
"compression": "ZSTD"
}
}

OCF

Configuration for OCF output with daily file rotation:

- id: 3
name: ocf_logs
type: file
properties:
location: "/var/log/vmetric"
type: "ocf"
compression: "zstd"
name: "logs_{{.Year}}_{{.Month}}_{{.Day}}.ocf"

Windows

Configuration for a Windows environment with a proper path structure:

- id: 4
name: windows_logs
type: file
properties:
location: "C:\\ProgramData\\VMetric\\Logs"
type: "json"
compression: "zstd"
name: "windows_{{.Year}}\\{{.Month}}\\system_logs.json"
warning

When no_buffer is enabled, each write operation will be immediately flushed to disk. This provides durability but may impact performance.