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

Fix clean_inactive for Filestream input #38632

Merged
merged 14 commits into from
Apr 12, 2024

Conversation

belimawr
Copy link
Contributor

@belimawr belimawr commented Mar 26, 2024

Proposed commit message

The clean_inactive parameter was being parsed with the wrong key. It
is parsed/used by an anonymous struct on input-logfile/manager.go,
there it was parsed and used as CleanTimeout (clean_timeout). This
CleanTimeout setting has got exactly the same effect as the
clean_inactive described in our documentation.

This commit fixes this bug by renaming clean_timeout to
clean_inactive so the configuration value can have effect.

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.

Author's Checklist

How to test this PR locally

All files are at the end of this section.

  1. Start Filebeat using filebeat.yml
  2. Create the file to be ingested/write some data
    echo "foo bar" > /tmp/log.log
    
  3. Look at Filebeat logs to ensure the file has been found, ingested and the reader was closed. Look for logs messages like those:
    A new file /tmp/log.log has been found
    Reader was closed. Closing. Path='/tmp/log.log
    
  4. Ensure the store clean up run and removed the only entry, look for a log message like:
    1 entries removed
    
  5. Ensure the registry log file (data/registry/filebeat/log.json) contains an remove operation like this:
    {"op":"remove","id":5}
    
filebeat.yml

filebeat.inputs:
  - type: filestream
    id: "test-clean-inactive"
    paths:
      - /tmp/log.log

    clean_inactive: 3s
    ignore_older: 2s
    close.on_state_change.inactive: 1s
    prospector.scanner.check_interval: 1s

filebeat.registry:
  cleanup_interval: 5s
  flush: 1s

queue.mem:
  events: 32
  flush.min_events: 8
  flush.timeout: 0.1s

path.home: %s

output.file:
  path: ${path.home}
  filename: "output-file"
  rotate_every_kb: 10000

logging:
  level: debug
  selectors:
    - input
    - input.filestream
  metrics:
    enabled: false

Related issues

## Use cases
## Screenshots
## Logs

@belimawr belimawr added bug Team:Elastic-Agent Label for the Agent team labels Mar 26, 2024
@botelastic botelastic bot added needs_team Indicates that the issue/PR needs a Team:* label and removed needs_team Indicates that the issue/PR needs a Team:* label labels Mar 26, 2024
Copy link
Contributor

mergify bot commented Mar 26, 2024

This pull request does not have a backport label.
If this is a bug or security fix, could you label this PR @belimawr? 🙏.
For such, you'll need to label your PR with:

  • The upcoming major version of the Elastic Stack
  • The upcoming minor version of the Elastic Stack (if you're not pushing a breaking change)

To fixup this pull request, you need to add the backport labels for the needed
branches, such as:

  • backport-v8./d.0 is the label to automatically backport to the 8./d branch. /d is the digit

@elasticmachine
Copy link
Collaborator

elasticmachine commented Mar 26, 2024

💚 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

  • Duration: 133 min 14 sec

❕ Flaky test report

No test was executed to be analysed.

🤖 GitHub comments

Expand to view the 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!)

@belimawr belimawr added the skip-ci Skip the build in the CI but linting label Mar 27, 2024
@belimawr belimawr force-pushed the fix-clean-inactive-v2 branch from a2fbcb8 to 75f4d84 Compare March 27, 2024 13:51
@belimawr belimawr marked this pull request as ready for review March 27, 2024 13:51
@belimawr belimawr requested a review from a team as a code owner March 27, 2024 13:51
@belimawr belimawr requested review from rdner and faec March 27, 2024 13:51
@elasticmachine
Copy link
Collaborator

Pinging @elastic/elastic-agent (Team:Elastic-Agent)

Copy link
Member

@rdner rdner left a comment

Choose a reason for hiding this comment

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

Also, the linter issue needs to be fixed.

CHANGELOG.next.asciidoc Outdated Show resolved Hide resolved
filebeat/input/v2/input-cursor/manager.go Outdated Show resolved Hide resolved
filebeat/tests/integration/filestream_test.go Outdated Show resolved Hide resolved
@belimawr belimawr force-pushed the fix-clean-inactive-v2 branch 2 times, most recently from 4ea05a5 to 2f7d96a Compare April 8, 2024 08:56
Copy link
Contributor

mergify bot commented Apr 9, 2024

This pull request is now in conflicts. Could you fix it? 🙏
To fixup this pull request, you can check out it locally. See documentation: https://help.github.com/articles/checking-out-pull-requests-locally/

git fetch upstream
git checkout -b fix-clean-inactive-v2 upstream/fix-clean-inactive-v2
git merge upstream/main
git push upstream fix-clean-inactive-v2

@belimawr belimawr force-pushed the fix-clean-inactive-v2 branch 2 times, most recently from 6c8e815 to b37756d Compare April 9, 2024 06:02
@@ -111136,6 +111136,13 @@ type: keyword

--

*`o365.audit.Activity`*::
Copy link
Contributor Author

Choose a reason for hiding this comment

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

This is unrelated to the PR, but when I run mage check it got generated.

@belimawr belimawr removed the skip-ci Skip the build in the CI but linting label Apr 9, 2024
@belimawr
Copy link
Contributor Author

belimawr commented Apr 9, 2024

/test

@pierrehilbert pierrehilbert requested a review from rdner April 9, 2024 12:44
@belimawr belimawr force-pushed the fix-clean-inactive-v2 branch from 9c594c4 to 866f57a Compare April 11, 2024 08:32
The `clean_inactive` parameter was being parsed with the wrong key. It
is parsed/used by an anonymous struct on `input-logfile/manager.go`,
there it was parsed and used as `CleanTimeout` (`clean_timeout`). This
`CleanTimeout` setting has got exactly the same effect as the
`clean_inactive` described in our documentation.

This commit fixes this bug by renaming `clean_timeout` to
`clean_inactive` so the configuration value can have effect.
- Rename `CleanTimeout` to `CleanInactive`
- Remove commented out code
@belimawr belimawr force-pushed the fix-clean-inactive-v2 branch from 866f57a to cba57bb Compare April 12, 2024 12:37
@cmacknz cmacknz merged commit ccd7b13 into elastic:main Apr 12, 2024
37 checks passed
@nimarezainia
Copy link
Contributor

Thank you all.

@jlind23 jlind23 added the QA:Needs Validation Needs validation by the QA Team label Apr 15, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug QA:Needs Validation Needs validation by the QA Team Team:Elastic-Agent Label for the Agent team
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Filestream ignores clean_inactive
6 participants