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

[filebeat] Check for duplicate ID for filestream metrics #35972

Merged

Conversation

taylor-swanson
Copy link
Contributor

@taylor-swanson taylor-swanson commented Jun 29, 2023

What does this PR do?

  • If a duplicate ID was used for filestream, set the ID for metrics to an empty string to prevent a panic.
  • A valid metrics instance will still be generated, but collection of metrics will not occur.

Why is it important?

Fixes a panic that can occur when a duplicate ID is used.

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.

How to test this PR locally

Create a config with duplicate IDs, such as:

filebeat:
  inputs:
    - type: filestream
      id: foo
      paths:
        - /tmp/foo
    - type: filestream
      id: foo
      paths:
        - /tmp/foo2
output:
  file:
    enabled: true

Run filebeat. The first instance should register with metrics. Subsequent instances will still register, but with an empty string. This still creates a valid metrics instance, but does not collect and report metrics.

Related issues

Logs

filestream input with ID 'foo' already exists, this will lead to data duplication, please use a different ID. Metrics collection has been disabled on this input.

{"log.level":"error","@timestamp":"2023-06-29T16:55:26.299Z","log.logger":"input","log.origin":{"file.name":"input-logfile/manager.go","file.line":183},"message":"filestream input with ID 'foo' already exists, this will lead to data duplication, please use a different ID. Metrics collection has been disabled on this input.","service.name":"filebeat","ecs.version":"1.6.0"}

- If a duplicate ID was used for filestream, set the ID for metrics
to an empty string to prevent a panic.
@taylor-swanson taylor-swanson self-assigned this Jun 29, 2023
@botelastic botelastic bot added the needs_team Indicates that the issue/PR needs a Team:* label label Jun 29, 2023
@mergify
Copy link
Contributor

mergify bot commented Jun 29, 2023

This pull request does not have a backport label.
If this is a bug or security fix, could you label this PR @taylor-swanson? 🙏.
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

@taylor-swanson taylor-swanson added backport-v8.9.0 Automated backport with mergify Team:Elastic-Agent Label for the Agent team and removed needs_team Indicates that the issue/PR needs a Team:* label labels Jun 29, 2023
@taylor-swanson taylor-swanson marked this pull request as ready for review June 29, 2023 17:00
@taylor-swanson taylor-swanson requested a review from a team as a code owner June 29, 2023 17:00
@elasticmachine
Copy link
Collaborator

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

@elasticmachine
Copy link
Collaborator

elasticmachine commented Jun 29, 2023

💚 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: 2023-06-30T18:52:50.989+0000

  • Duration: 69 min 29 sec

Test stats 🧪

Test Results
Failed 0
Passed 7996
Skipped 757
Total 8753

💚 Flaky test report

Tests succeeded.

🤖 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!)

@taylor-swanson taylor-swanson merged commit f7fa407 into elastic:main Jul 3, 2023
@taylor-swanson taylor-swanson deleted the filestream-metrics-duplicate-id branch July 3, 2023 16:53
mergify bot pushed a commit that referenced this pull request Jul 3, 2023
- If a duplicate ID was used for filestream, set the ID for metrics
to an empty string to prevent a panic.
- A valid metrics instance will still be generated, but collection of
metrics will not occur.

(cherry picked from commit f7fa407)
taylor-swanson added a commit that referenced this pull request Jul 3, 2023
…5987)

- If a duplicate ID was used for filestream, set the ID for metrics
to an empty string to prevent a panic.
- A valid metrics instance will still be generated, but collection of
metrics will not occur.

(cherry picked from commit f7fa407)

Co-authored-by: Taylor Swanson <90622908+taylor-swanson@users.noreply.github.com>
Scholar-Li pushed a commit to Scholar-Li/beats that referenced this pull request Feb 5, 2024
- If a duplicate ID was used for filestream, set the ID for metrics
to an empty string to prevent a panic.
- A valid metrics instance will still be generated, but collection of
metrics will not occur.
@VannTen
Copy link

VannTen commented May 24, 2024

It looks like this did not completely fix the issue, see #35964 (comment)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
backport-v8.9.0 Automated backport with mergify bug Filebeat Filebeat Team:Elastic-Agent Label for the Agent team
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Filestream inputs with duplicated ID cause Filebeat to panic
4 participants