I am exporting traces and logs to a json file as below using Open Telemetry. The problem here is, the file is increasing day by day on the container. Is there a way we can limit the file size to 10 MB in the below configuration?
exporters:
# Data sources: traces, metrics, logs
file:
path: ./filename.json
In docker, we have the option to do this like below. Is there a similar option to do it in the opentelemetry exporter?
logging:
driver: "json-file"
options:
max-size: "2m"
max-file: "10"
labels: "collector"
env: "test"
2
Answers
That’s not possible https://github.com/open-telemetry/opentelemetry-collector-contrib/tree/main/exporter/fileexporter
File exporter is intended for primarily for debugging Collector without setting up backends, not for prod running. So your requested feature does not make sense for intented use case.
File-rotation support is now available in
fileexporter
:https://github.com/open-telemetry/opentelemetry-collector-contrib/tree/main/exporter/fileexporter#file-rotation
For your settings, I think this would look something like: