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 system module with both filesets enabled #41381

Merged

Conversation

belimawr
Copy link
Contributor

@belimawr belimawr commented Oct 22, 2024

Proposed commit message

The system module did not define an ID at the root of the config, that made the V2 input loader only start the first journald input it saw because they both ended up with the same identifier (type, ID and path). This is fixed by defining an ID at the root of the configuration templates.

The journald input now also adds the input_id key to its loggers and a non-fatal error is now logged at debug level.

The system-logs input is now marked as experimental instead of stable.

Fix lint warnings by moving toJournalConfig to input_linux.go

Move TestSystemLogsCanUseLogInput to a file without the
linux build constraint so it can run on all OSes supported by the
system integration.

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.

## Disruptive User Impact
## Author's Checklist

How to test this PR locally

  1. Run Filebeat with the following filebeat.yml and modules.d/system.yml (adjust credentials/addresses as necessary)

    filebeat.yml

    filebeat.inputs:
      - type: journald
        id: my-journald-normal-input
        tags:
           - journald-input
      - type: filestream
        id: my-filestream-id
        paths:
          - /tmp/flog.log
    
    filebeat.config.modules:
      path: ${path.config}/modules.d/*.yml
      reload.enabled: false
      reload.period: 1s
    
    setup.template:
      settings:
        index.number_of_shards: 1
    
    setup.kibana:
      host: "http://kibana:5601"
      username: admin
      password: testing
      ssl.verification_mode: none
    
    output.elasticsearch:
      hosts: ["http://elasticsearch:9200"]
      preset: latency
      protocol: "http"
    
      username: admin
      password: testing
      ssl.verification_mode: none

    modules.d/system.yml

    - module: system
      syslog:
        enabled: true
        var.use_journald: true
        input:
          tags:
            - from-journald
    
      auth:
        enabled: true
        var.use_journald: true
        var.tags:
          - from-journald

  2. Go to Discover in Kibana, filter by tags: from-journald

  3. Look at fileset.name from the events, make sure auth and syslog are there

Related issues

## Use cases
## Screenshots
## Logs

@belimawr belimawr added bug Team:Elastic-Agent-Data-Plane Label for the Agent Data Plane team backport-8.x Automated backport to the 8.x branch with mergify backport-8.16 Automated backport with mergify labels Oct 22, 2024
@belimawr belimawr self-assigned this Oct 22, 2024
@belimawr belimawr requested a review from a team as a code owner October 22, 2024 20:48
@elasticmachine
Copy link
Collaborator

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

@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 Oct 22, 2024
@belimawr belimawr force-pushed the 41378-fix-system-module-only-starts-one-input branch from 0765233 to 0501772 Compare October 22, 2024 22:35
@belimawr belimawr changed the title Fix system module with both filesets enables Fix system module with both filesets enabled Oct 22, 2024
@belimawr belimawr force-pushed the 41378-fix-system-module-only-starts-one-input branch from 0501772 to 59b7cb6 Compare October 22, 2024 23:37
@pierrehilbert pierrehilbert requested review from rdner and mauri870 and removed request for khushijain21 and VihasMakwana October 23, 2024 08:42
Copy link
Member

@mauri870 mauri870 left a comment

Choose a reason for hiding this comment

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

I don't see the linter change nor the comment for the journald stdout, did you forgot to push?

Copy link
Contributor

mergify bot commented Oct 23, 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 41378-fix-system-module-only-starts-one-input upstream/41378-fix-system-module-only-starts-one-input
git merge upstream/main
git push upstream 41378-fix-system-module-only-starts-one-input

@belimawr belimawr force-pushed the 41378-fix-system-module-only-starts-one-input branch 2 times, most recently from 59974d2 to d25f496 Compare October 23, 2024 21:40
@belimawr
Copy link
Contributor Author

Some CI failures seem to be unrelated:

<html>
<body>
<!--StartFragment-->
=== Failed
--
  | === FAIL: filebeat/input/filestream/internal/task TestGroup_Go/workloads_wait_for_available_worker (0.20s)
  | group_test.go:129: f2 started
  | group_test.go:116: f1 started
  | group_test.go:135: f2 done
  | group_test.go:148: f3 started
  | group_test.go:182: waiting the worker pool to finish all workloads
  | group_test.go:118: f1 done
  | group_test.go:150: f3 done
  | group_test.go:185: worker pool to finished all workloads
  | group_test.go:187:
  | Error Trace:	C:/buildkite-agent/builds/bk-agent-prod-gcp-1729720802417888488/elastic/filebeat/filebeat/input/filestream/internal/task/group_test.go:187
  | Error:      	Condition never satisfied
  | Test:       	TestGroup_Go/workloads_wait_for_available_worker
  | Messages:   	not all goroutines finished
  |  
  | === FAIL: filebeat/input/filestream/internal/task TestGroup_Go (0.70s)

<!--EndFragment-->
</body>
</html>

BK link: https://buildkite.com/elastic/filebeat/builds/10493#0192bb64-7d3a-4e8a-9879-e4528b7076ab/154-388

I tried to reproduce it on Win and did not succeed. I'll just re-run, if it fails again I'll open a FlakyTest issue.

@mauri870
Copy link
Member

@belimawr This test looks suspiciously like the other ones I fixed recently #41230. I wouldn't be surprised if it is flaky.

@belimawr belimawr requested a review from a team as a code owner October 24, 2024 15:42
Fix lint warnings and add Linux build tag in the files that were
missing it.
Skip TestSystemLogsCanUseJournaldInput if on BuildKite and not running
as root, running commands as root is also fixed.
Journald input only works on Linux because Systemd is only available
for Linux, so remove any file from the journald input that are built
on OSes other than Linux.

All integration test helpers from system-logs input are moved to a
file that is build on all platforms.
@belimawr belimawr force-pushed the 41378-fix-system-module-only-starts-one-input branch from 9759879 to 49e5076 Compare October 29, 2024 18:52
Copy link
Contributor

@rowlandgeoff rowlandgeoff left a comment

Choose a reason for hiding this comment

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

BK pipeline change looks good

@belimawr belimawr merged commit b1c7478 into elastic:main Oct 30, 2024
141 checks passed
mergify bot pushed a commit that referenced this pull request Oct 30, 2024
The system module did not define an ID at the root of the config, that made the V2 input loader only start the first journald input it saw because they both ended up with the same identifier (type, ID and path). This is fixed by defining an ID at the root of the configuration templates.

The journald input now also adds the input_id key to its loggers and a non-fatal error is now logged at debug level.

The system-logs input is now marked as experimental instead of stable.

Fix lint warnings by moving toJournalConfig to input_linux.go

Move TestSystemLogsCanUseLogInput to a file without the
linux build constraint so it can run on all OSes supported by the
system integration.

(cherry picked from commit b1c7478)

# Conflicts:
#	.buildkite/filebeat/filebeat-pipeline.yml
mergify bot pushed a commit that referenced this pull request Oct 30, 2024
The system module did not define an ID at the root of the config, that made the V2 input loader only start the first journald input it saw because they both ended up with the same identifier (type, ID and path). This is fixed by defining an ID at the root of the configuration templates.

The journald input now also adds the input_id key to its loggers and a non-fatal error is now logged at debug level.

The system-logs input is now marked as experimental instead of stable.

Fix lint warnings by moving toJournalConfig to input_linux.go

Move TestSystemLogsCanUseLogInput to a file without the
linux build constraint so it can run on all OSes supported by the
system integration.

(cherry picked from commit b1c7478)

# Conflicts:
#	.buildkite/filebeat/filebeat-pipeline.yml
belimawr added a commit that referenced this pull request Nov 1, 2024
…41488)

Even though the System module is not using the system-logs input any more, this commit brings improvements
to the Journald input and to the, currently skipped, system-logs + system module tests.

Original commit message:

The system module did not define an ID at the root of the config, that made the V2 input loader only start the first journald input it saw because they both ended up with the same identifier (type, ID and path). This is fixed by defining an ID at the root of the configuration templates.

The journald input now also adds the input_id key to its loggers and a non-fatal error is now logged at debug level.

The system-logs input is now marked as experimental instead of stable.

Fix lint warnings by moving toJournalConfig to input_linux.go

Move TestSystemLogsCanUseLogInput to a file without the
linux build constraint so it can run on all OSes supported by the
system integration.

(cherry picked from commit b1c7478)

# Conflicts:
#	.buildkite/filebeat/filebeat-pipeline.yml

* Fix filebeat-pipeline.yml merge conflict

* skip system-logs test

---------

Co-authored-by: Tiago Queiroz <[email protected]>
Co-authored-by: Geoff Rowland <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
backport-8.x Automated backport to the 8.x branch with mergify backport-8.16 Automated backport with mergify bug 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.

[System module] Only one instance of Journald runs when both syslog and auth filesets are enabled
6 participants