如何拆分opentelemetry文件出口商输出文件

发布于 2025-01-20 07:55:50 字数 425 浏览 0 评论 0 原文

我正在使用 Open Telemetry 将跟踪和日志导出到 json 文件,如下所示。这里的问题是,容器上的文件每天都在增加。有没有办法可以在下面的配置中将文件大小限制为 10 MB?

exporters:
# Data sources: traces, metrics, logs
  file:
    path: ./filename.json

在 docker 中,我们可以选择像下面这样执行此操作。在 opentelemetry 导出器中是否有类似的选项可以执行此操作?

logging:
  driver: "json-file"
  options:
    max-size: "2m"
    max-file: "10"
    labels: "collector"
    env: "test"

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"

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

蝶…霜飞 2025-01-27 07:55:50

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.

韬韬不绝 2025-01-27 07:55:50

fileexporter 现已提供文件轮换支持:

https://github.com/open-telemetry/opentelemetry-collector-contrib/tree/main/exporter/fileexporter#file-rotation

对于您的设置,我认为这看起来像:

exporters:
  file:
    path: ./log_basename
    rotation:
      max_megabytes: 2
      max_backups: 10

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
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文