0

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"
Jan Garaj
  • 25,598
  • 3
  • 38
  • 59
Jagan
  • 1

2 Answers2

0

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.

Jan Garaj
  • 25,598
  • 3
  • 38
  • 59
0

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:

exporters:
  file:
    path: ./log_basename
    rotation:
      max_megabytes: 2
      max_backups: 10
psigen
  • 163
  • 1
  • 2
  • 9