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

Remove logging.files.suffix option and always use datetime suffixes #28927

Merged
merged 20 commits into from
Nov 22, 2021

Conversation

kvch
Copy link
Contributor

@kvch kvch commented Nov 11, 2021

What does this PR do?

This PR contains several improvements to the output file log rotation:

  • Removes suffix option as discussed offline
  • Filenames end in extension name so users get a hint about the contents
  • Removes time.Sleep from testing code
  • Datetime format no longer contains hour and minutes. In case of conflict on rotation, an index is appended to the filename.

Why is it important?

Previously, log file suffixes were configurable. Users had the option to either add the count or the datetime to the end of the log file. From now on, we only allow datetime based naming. Hence the configuration option logging.files.suffix is removed.

Example:
Filebeat is writing logs to filebeat-20211111.ndjson actively. Then a few minutes later it gets rotated, and the new active file becomes filebeat-20211111-1.ndjson.

This change should help with Beats not being able to rotate files on Windows.

Checklist

  • My code follows the style guidelines of this project
  • I have commented my code, particularly in hard-to-understand areas
  • I have made corresponding changes to the documentation
  • I have made corresponding change to the default configuration files
  • I have added tests that prove my fix is effective or that my feature works
  • I have added an entry in CHANGELOG.next.asciidoc or CHANGELOG-developer.next.asciidoc.

@botelastic botelastic bot added the needs_team Indicates that the issue/PR needs a Team:* label label Nov 11, 2021
@mergify
Copy link
Contributor

mergify bot commented Nov 11, 2021

This pull request does not have a backport label. Could you fix it @kvch? 🙏
To fixup this pull request, you need to add the backport labels for the needed
branches, such as:

  • backport-v./d./d./d is the label to automatically backport to the 7./d branch. /d is the digit

NOTE: backport-skip has been added to this pull request.

@mergify mergify bot added the backport-skip Skip notification from the automated backport with mergify label Nov 11, 2021
@elasticmachine
Copy link
Collaborator

elasticmachine commented Nov 11, 2021

💚 Build Succeeded

the below badges are clickable and redirect to their specific view in the CI or DOCS
Pipeline View Test View Changes Artifacts preview preview

Expand to view the summary

Build stats

  • Start Time: 2021-11-19T14:17:48.142+0000

  • Duration: 159 min 54 sec

  • Commit: 2ff01b3

Test stats 🧪

Test Results
Failed 0
Passed 48922
Skipped 4295
Total 53217

💚 Flaky test report

Tests succeeded.

🤖 GitHub comments

To re-run your PR in the CI, just comment with:

  • /test : Re-trigger the build.

  • /package : Generate the packages and run the E2E tests.

  • /beats-tester : Run the installation tests with beats-tester.

  • run elasticsearch-ci/docs : Re-trigger the docs validation. (use unformatted text in the comment!)

@kvch kvch added the Team:Elastic-Agent-Data-Plane Label for the Agent Data Plane team label Nov 16, 2021
@botelastic botelastic bot removed the needs_team Indicates that the issue/PR needs a Team:* label label Nov 16, 2021
@kvch kvch added backport-v8.0.0 Automated backport with mergify needs_team Indicates that the issue/PR needs a Team:* label labels Nov 16, 2021
@botelastic botelastic bot removed the needs_team Indicates that the issue/PR needs a Team:* label label Nov 16, 2021
@botelastic
Copy link

botelastic bot commented Nov 16, 2021

This pull request doesn't have a Team:<team> label.

@mergify mergify bot removed the backport-skip Skip notification from the automated backport with mergify label Nov 16, 2021
@kvch kvch changed the title Remove libbeat log suffix type Remove logging.files.suffix option and always use datetime suffixes Nov 16, 2021
@kvch kvch requested a review from faec November 16, 2021 16:56
@kvch kvch marked this pull request as ready for review November 16, 2021 16:56
@kvch kvch requested review from a team as code owners November 16, 2021 16:56
@elasticmachine
Copy link
Collaborator

Pinging @elastic/elastic-agent-data-plane (Team:Elastic-Agent-Data-Plane)

Copy link
Contributor

@faec faec left a comment

Choose a reason for hiding this comment

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

This looks really nice!

@@ -158,7 +147,7 @@ func NewFileRotator(filename string, options ...RotatorOption) (*Rotator, error)
permissions: 0600,
interval: 0,
rotateOnStartup: true,
suffix: SuffixCount,
clock: &realClock{},
Copy link
Contributor

Choose a reason for hiding this comment

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

injectible clock makes me happy :-)

@kvch
Copy link
Contributor Author

kvch commented Nov 19, 2021

/package

@kvch kvch merged commit f2ae281 into elastic:master Nov 22, 2021
mergify bot pushed a commit that referenced this pull request Nov 22, 2021
…#28927)

## What does this PR do?

This PR contains several improvements to the output file log rotation:
* Removes suffix option as discussed offline
* Filenames end in extension name so users get a hint about the contents
* Removes `time.Sleep` from testing code
* Datetime format no longer contains hour and minutes. In case of conflict on rotation, an index is appended to the filename.

## Why is it important?

Previously, log file suffixes were configurable. Users had the option to either add the count or the datetime to the end of the log file. From now on, we only allow datetime based naming. Hence the configuration option `logging.files.suffix` is removed.

Example:
Filebeat is writing logs to `filebeat-20211111.ndjson` actively. Then a few minutes later it gets rotated, and the new active file becomes `filebeat-20211111-1.ndjson`.

This change should help with Beats not being able to rotate files on Windows.

(cherry picked from commit f2ae281)
kvch added a commit that referenced this pull request Nov 22, 2021
…#28927) (#29065)

## What does this PR do?

This PR contains several improvements to the output file log rotation:
* Removes suffix option as discussed offline
* Filenames end in extension name so users get a hint about the contents
* Removes `time.Sleep` from testing code
* Datetime format no longer contains hour and minutes. In case of conflict on rotation, an index is appended to the filename.

## Why is it important?

Previously, log file suffixes were configurable. Users had the option to either add the count or the datetime to the end of the log file. From now on, we only allow datetime based naming. Hence the configuration option `logging.files.suffix` is removed.

Example:
Filebeat is writing logs to `filebeat-20211111.ndjson` actively. Then a few minutes later it gets rotated, and the new active file becomes `filebeat-20211111-1.ndjson`.

This change should help with Beats not being able to rotate files on Windows.

(cherry picked from commit f2ae281)

Co-authored-by: Noémi Ványi <[email protected]>
v1v added a commit to v1v/beats that referenced this pull request Nov 22, 2021
…ws-on-file-changes

* upstream/master:
  Fix discovery of Nomad allocations (elastic#28700)
  Add null (`\u0000`) as a valid line terminator (elastic#28998)
  Remove `logging.files.suffix` option and always use datetime suffixes (elastic#28927)
  x-pack/filebeat/module: add note for default var.input (elastic#28324)
  Fix AccessList & AccessMask processing in security data_stream (elastic#29016)
  [Metricbeat] Fix wrong mapping on "info" subkey (elastic#28782)
  ci: daily/weekly jobs (elastic#29050)
  [mergify] report open backported PRs once a week (elastic#28964)
@andrewkroh
Copy link
Member

@kvch The docs and config for the file output appear to not match the new behavior:

# Name of the generated files. The default is `{{.BeatName}}` and it generates
# files: `{{.BeatName}}`, `{{.BeatName}}.1`, `{{.BeatName}}.2`, etc.
#filename: {{.BeatName}}

===== `filename`
The name of the generated files. The default is set to the Beat name. For example, the files
generated by default for {beatname_uc} would be "{beatname_lc}", "{beatname_lc}.1", "{beatname_lc}.2", and so on.

@kvch
Copy link
Contributor Author

kvch commented Dec 17, 2021

Yes, it has been on my TODO list. I've just opened PR: #29501

belimawr pushed a commit that referenced this pull request Dec 22, 2021
* Follow up changes in the docs for logging
* add reference configuration
mergify bot pushed a commit that referenced this pull request Dec 22, 2021
* Follow up changes in the docs for logging
* add reference configuration

(cherry picked from commit 391a948)
belimawr pushed a commit that referenced this pull request Dec 23, 2021
* Follow up changes in the docs for logging
* add reference configuration

(cherry picked from commit 391a948)

Co-authored-by: Noémi Ványi <[email protected]>
simitt added a commit to simitt/beats-tester that referenced this pull request Dec 31, 2021
This fixes the tests for beats and apm-server when checking for the output files.
Relates to changes from elastic/beats#28927
simitt added a commit to simitt/beats-tester that referenced this pull request Jan 5, 2022
This fixes the tests for beats when checking for the output files.
Relates to changes from elastic/beats#28927
Add output ndjson suffix to APM Server output (unclear why this is necessary).

* Increase timeout for output file and ensure it is written.

The output file is only written when some actual values are processed. Enable
self-instrumentation for APM to ensure the output file is written and increase
timeout. For beats, enable metrics logging explicitly.
simitt added a commit to simitt/beats-tester that referenced this pull request Jan 5, 2022
This fixes the tests for beats when checking for the output files.
Relates to changes from elastic/beats#28927
Add output ndjson suffix to APM Server output (unclear why this is necessary).

* Increase timeout for output file and ensure it is written.

The output file is only written when some actual values are processed. Enable
self-instrumentation for APM to ensure the output file is written and increase
timeout. For beats, enable metrics logging explicitly.

* Disable failing beats issues

A follow up is necessary to fix and enable these tests if still useful.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
backport-v8.0.0 Automated backport with mergify Team:Elastic-Agent-Data-Plane Label for the Agent Data Plane team
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants