open-telemetry / opentelemetry-collector

OpenTelemetry Collector
https://opentelemetry.io
Apache License 2.0
4.42k stars 1.46k forks source link

Log rotation for telemetry logs #7507

Open esaabdk opened 1 year ago

esaabdk commented 1 year ago

Hi,

Does telemetry logs provides any configuration to rotate logs ? Based on log configuration provided in collector yaml file, I couldn't find any option for log rotation. Please clarify.

Also, since open telemetry collector agent uses Zap logger, I found another log library called lumberjack, which can be used in conjunction with Zap to enable log rotation.

In order to achieve it, Lumberjack instance need to be set in Zap logger during application start-up like below,

log.SetOutput(&lumberjack.Logger{ Filename: "/var/log/myapp/foo.log", MaxSize: 500, // megabytes MaxBackups: 3, MaxAge: 28, //days Compress: true, // disabled by default })

Can you help me here on where I set this in open telemetry collector agent? I am currently using custom otel collector agent by creating a custom processor for my use case.

Please let me know for any further details.

h0cheung commented 1 year ago

We have an open pr. You can try it out. https://github.com/open-telemetry/opentelemetry-collector/pull/7425