otelcol.storage.file
Public preview: This is a public preview component. Public preview components are subject to breaking changes, and may be replaced with equivalent functionality that cover the same use case. To enable and use a public preview component, you must set the
stability.levelflag topublic-previewor below.
otelcol.storage.file exposes a handler that other otelcol components can use to write state to a local directory.
The current implementation of this component uses bbolt to store and read data on disk.
Note
otelcol.storage.fileis a wrapper over the upstream OpenTelemetry Collectorfilestorageextension. Bug reports or feature requests will be redirected to the upstream repository, if necessary.
You can specify multiple otelcol.storage.file components by giving them different labels.
Usage
otelcol.storage.file "<LABEL>" {
}Arguments
You can use the following arguments with otelcol.storage.file:
The default directory used for file storage is a subdirectory of the data-alloy directory located in the Alloy working directory.
This will vary depending on the path specified by the command line flag --storage-path.
create_directory is false by default in the upstream receiver.
create_directory is true by default in Alloy because directory defaults to the data-alloy path in Alloy and that directory is owned by the Alloy process.
Blocks
You can use the following blocks with otelcol.storage.file:
compaction
The compaction block defines the compaction parameters for the file storage.
The default directory used for file storage is a subdirectory of the data-alloy directory located in the Alloy working directory.
This will vary depending on the path specified by the command line flag --storage-path.
If on_rebound online compaction is enabled, compaction will be triggered when total allocated data is greater than rebound_needed_threshold_mib and used allocated data is less than rebound_trigger_threshold_mib.
More detailed information about the way the component supports file compaction for allocated disk storage recovery can be found in the upstream component’s documentation.
debug_metrics
The debug_metrics block configures the metrics that this component generates to monitor its state.
The following arguments are supported:
disable_high_cardinality_metrics is the Alloy equivalent to the telemetry.disableHighCardinalityMetrics feature gate in the OpenTelemetry Collector.
It removes attributes that could cause high cardinality metrics.
For example, attributes with IP addresses and port numbers in metrics about HTTP and gRPC connections are removed.
Note
If configured,
disable_high_cardinality_metricsonly applies tootelcol.exporter.*andotelcol.receiver.*components.
Exported fields
The following fields are exported and can be referenced by other components:
Component health
otelcol.storage.file is only reported as unhealthy if given an invalid configuration.
Debug information
otelcol.storage.file doesn’t expose any component-specific debug information.
Examples
otelcol.receiver.filelog
This examples uses an otelcol.storage.file component to store file offsets for an otelcol.receiver.filelog component.
This will only use a small amount of data for each file that has been read so it’s unlikely that you will need to be concerned about compaction settings.
The default settings of the component will place the bbolt file for the receiver in <STORAGE_PATH>/otelcol.storage.file.default/receiver_filelog_default
otelcol.storage.file "default" {}
otelcol.receiver.filelog "default" {
include = ["/var/log/*.log"]
storage = otelcol.storage.file.default.handler
operators = [{
type = "regex_parser",
regex = "^(?P<timestamp>[^ ]+)",
timestamp = {
parse_from = "attributes.timestamp",
layout = "%Y-%m-%dT%H:%M:%S.%fZ",
location = "UTC",
},
}]
output {
logs = [otelcol.exporter.debug.default.input]
}
}
otelcol.exporter.debug "default" {}


