-
Notifications
You must be signed in to change notification settings - Fork 432
otelcol.exporter.file: add file exporter component with configu… #4475
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
madhub seems not to be a GitHub user. You need a GitHub account to be able to sign the CLA. If you have already a GitHub account, please add the email address used for this commit to your account. You have signed the CLA already but the status is still pending? Let us recheck it. |
|
There are some changes we need to make to the docs, but.. they are a lot to put into the GitHub webUI. Would you mind if I edited the doc input in your fork and pushed back to GitHub? |
Pls go-ahead |
@madhub I've made some changes to the doc and pushed to your branch. The changes are primarily style and linting. I reorganized a few bits to conform a bit better to the general style currently in-use in the component docs. I also added the metadata and othe rinfo for Community written/supported components. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ok
@clayton-cornell anything pending from my side ?, |
Next is a code review from @grafana/grafana-alloy-maintainers |
Is this extension with the "compression: zstd" feature enabled not adding a filename extension? I see the testing code includes cases with compression and filename ".json" otelcol.exporter.file "compressed" {
path = "/tmp/traces.jsonl"
format = "proto"
compression = "zstd"
} alloyCfg := `
path = "/tmp/*/test.json"
format = "json"
append = false
compression = "zstd"
flush_interval = "5s"
rotation {
max_megabytes = 50
max_days = 7
max_backups = 10
localtime = true
}
group_by {
enabled = true
resource_attribute = "service.name"
max_open_files = 50
} I searched for ".zst" or ".gz" and found no references in the code |
|
I see in the repo you linked that for other contrib exporter and other compression algorithm it appended ".gz" to the files without specifying: |
I tested it with zstd, and it seems the file is Zstd-compressed with a length prefix. This behavior is also documented here https://github.com/open-telemetry/opentelemetry-collector-contrib/blob/main/exporter/fileexporter/README.md#file-format Here is the sample output after removing the 4 bytes. You can clearly see zstd magic string ![]() For Reference
|
Thanks for the demonstration. It seems to have produced output in some format that could be characterized by file extension labels Unrelated to this MR, just as an aside, it seems to have added a byte count even when using json format, while documented behaviour appears to indicate that it's only added for protocol buffers |
I also tried setting the format to
![]() |
My doubts are resolved, I'm not an approver/reviewer. In my view, the result of the compression is as they are coded for in the dependencies opentelemetry-contrib, the problem I see, in general the file type prefixed by length is not adequately labeled by a file extension. From this point onwards I'm not talking about the merge, but the behaviour of added dependencies as per your helpful demonstrations: If/and/when this is used, if the users aren't aware of the behaviour, many backed-up outputs may get discarded as unprocessable/corrupted if they don't strip out the length prefix (even in json, where the readme says it shouldn't appear), or aren't configuring alloy to append the compression file extension '.zst' suffix. There is also no hashing to ensure that the length prefix was calculated for the right ensuing payload contents, it would be rather easy to zero-out and re-write the prefix with any other amount that ensures allocated memory will not suffice. I think the general approach could be to store the hash of the length size alongside the payload, and prefix with the hash of both, then calculate the hash before trusting the length, to ensure it's not tampered with, otherwise consider the length prefix as not being present. Only issue is that this nullifies the desired effect of not needing to load the full file before allocating. |
This pull request introduces a new
otelcol.exporter.file
component, which allows metrics, logs, and traces to be written to disk with options for rotation, compression, and grouping by resource attribute. The implementation includes documentation, code, dependency updates, and thorough validation and testing. This addition enables users to persist telemetry data locally in either JSON or Protocol Buffers format and provides flexible configuration for file management.New Feature: File Exporter Component
otelcol.exporter.file
component, enabling telemetry data export to disk with support for file rotation, compression (zstd), and grouping output files by resource attribute. The component wraps the upstream OpenTelemetry Collector Contribfileexporter
. [1] [2]Documentation and Usage
otelcol.exporter.file
, detailing arguments, blocks (rotation, group_by, debug_metrics), configuration options, usage examples, and technical details.Codebase Integration
all.go
).Dependency Management
github.com/open-telemetry/opentelemetry-collector-contrib/exporter/fileexporter
as a dependency ingo.mod
to support the new exporter.Validation and Testing
This change provides a flexible and robust mechanism for exporting telemetry data to files, suitable for local debugging, archival, or integration with other file-based workflows.…ration options
PR Description
Which issue(s) this PR fixes
Fixes #4398
Notes to the Reviewer
Following tests were done
Formatting test with file exporter
./alloy fmt example-file-exporter.alloy
Run test with file OTLP input & file export
./alloy run test-file-exporter.alloy
Conversion test OpenTelemetry configuration and converting it to alloy
./alloy run test-file-exporter.alloy
End 2 end test : OTLP input , file export & sending sample OTel Log record using Curl
./alloy run test-converted.alloy
Alloy configuration used for testing
Example test message sent via curl
PR Checklist