skip to Main Content

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


  1. 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.

    Login or Signup to reply.
  2. 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
    
    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search