Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Log rotation #5778

Merged
merged 3 commits into from
May 3, 2019
Merged

Log rotation #5778

merged 3 commits into from
May 3, 2019

Conversation

javicrespo
Copy link
Contributor

@javicrespo javicrespo commented Apr 28, 2019

Concerns #3393

I took the code from #5547 as a basis and did the following:

  • created a reusable rotation-aware file writer
  • added additional rotation features (maxsize, maxarchives)
  • wrote unit tests.

This PR uses the new file writer for logging purposes only, but it can be easily plugged in the output file plugin.

Required for all PRs:

  • Signed CLA.
  • Associated README.md updated.
  • Has appropriate unit tests.

@javicrespo javicrespo marked this pull request as ready for review April 28, 2019 11:22
@Jaeyo
Copy link
Contributor

Jaeyo commented Apr 28, 2019

+1

internal/rotate/file_writer.go Outdated Show resolved Hide resolved
internal/rotate/file_writer.go Outdated Show resolved Hide resolved
internal/rotate/file_writer.go Outdated Show resolved Hide resolved
logger/logger.go Outdated Show resolved Hide resolved
logger/logger.go Outdated Show resolved Hide resolved
internal/rotate/file_writer.go Outdated Show resolved Hide resolved
internal/rotate/file_writer.go Show resolved Hide resolved
internal/rotate/file_writer.go Outdated Show resolved Hide resolved
internal/rotate/file_writer.go Outdated Show resolved Hide resolved
internal/rotate/file_writer.go Show resolved Hide resolved
@danielnelson danielnelson added area/agent feat Improvement on an existing feature such as adding a new setting/mode to an existing plugin labels May 1, 2019
@danielnelson danielnelson added this to the 1.11.0 milestone May 3, 2019
@danielnelson danielnelson merged commit bcf7516 into influxdata:master May 3, 2019
hwaastad pushed a commit to hwaastad/telegraf that referenced this pull request Jun 13, 2019
// Use year-month-date for readability, unix time to make the file name unique with second precision
now := time.Now()
rotatedFilename := fmt.Sprintf(w.filenameRotationTemplate, now.Format(DateFormat), strconv.FormatInt(now.Unix(), 10))
if err = os.Rename(w.filename, rotatedFilename); err != nil {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe compress the rotated file?
https://www.dotnetperls.com/compress-go

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good idea, mind opening a new feature request for compressing the rotated files since this pr has been merged, thanks.

bitcharmer pushed a commit to bitcharmer/telegraf that referenced this pull request Oct 18, 2019
athoune pushed a commit to bearstech/telegraf that referenced this pull request Apr 17, 2020
idohalevi pushed a commit to idohalevi/telegraf that referenced this pull request Sep 29, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area/agent feat Improvement on an existing feature such as adding a new setting/mode to an existing plugin
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants