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

Journald support for System module #41555

Merged
merged 11 commits into from
Nov 18, 2024

Conversation

belimawr
Copy link
Contributor

@belimawr belimawr commented Nov 7, 2024

Proposed commit message

This commit adds journald support for the System module, both filesets now have a use_journald variable
that can be set to force using Journald to ingest syslog and auth logs.

The ingest pipelines are updated, now there is an entrypoint pipeline that selects the correct one according to the field
input.type.

System tests are also added.

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

  • Ensure the journald input is ingesting data correctly

How to test this PR locally

  1. Package Filebeat from this PR
  2. Configure the ES output and Kibana credentials
  3. Enable the system module (./filebeat modules enable system), set var.use_journald: true for both filesets (edit modules.d/system.yml)
  4. Setup the assets: ./filebeat setup --modules system (this requires Kibana credentials correctly set)
  5. Run Filebeat as root
  6. Look at the logs in the filebeat-* data view, filter by event.dataset: system.syslog or event.dataset: system.auth, ensure the logs are correctly ingested
  7. Look at the system module dashboards, ensure they're working/show data.

Related issues

## Use cases

Screenshots

Dashboards, journald and logs side by side

2024-11-08_10-54
2024-11-08_10-54_1
2024-11-08_10-55
2024-11-08_10-55_1

Events, journald and logs side by side

2024-11-08_10-59

~~## Logs~~

@belimawr belimawr added the Team:Elastic-Agent-Data-Plane Label for the Agent Data Plane team label Nov 7, 2024
@belimawr belimawr self-assigned this Nov 7, 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 Nov 7, 2024
Copy link
Contributor

mergify bot commented Nov 7, 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-8./d is the label to automatically backport to the 8./d branch. /d is the digit

Copy link
Contributor

mergify bot commented Nov 7, 2024

backport-8.x has been added to help with the transition to the new branch 8.x.
If you don't need it please use backport-skip label and remove the backport-8.x label.

@mergify mergify bot added the backport-8.x Automated backport to the 8.x branch with mergify label Nov 7, 2024
@belimawr
Copy link
Contributor Author

belimawr commented Nov 8, 2024

I've been doing a comparison test between the system module with journald and log input, and they report a different amount of messages, there are more entries in the log files than in the journal. I did this test on a fresh Debian 11 VM that uses both: jouranld and traditional log files (via rsyslog):

root@bullseye:/var/log# wc -l syslog auth.log messages 
   679 syslog
   147 auth.log
   423 messages
  1249 total
root@bullseye:/var/log# journalctl --no-tail | wc -l
919
root@bullseye:/var/log# 

The dashboards seem correctly populated (screenshots in the PR description).

I'm still investigating this difference.

@belimawr belimawr marked this pull request as ready for review November 13, 2024 15:56
@belimawr belimawr requested a review from a team as a code owner November 13, 2024 15:56
@belimawr belimawr requested review from AndersonQ and rdner November 13, 2024 15:56
@elasticmachine
Copy link
Collaborator

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

Copy link
Member

Choose a reason for hiding this comment

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

any reason for not placing it inside a testdata folder?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yes, I placed it where the other test files are. Those are used by the python system tests.

Copy link
Member

Choose a reason for hiding this comment

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

any reason for not placing it inside a testdata folder?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yes, I placed it where the other test files are. Those are used by the python system tests.

@AndersonQ
Copy link
Member

I've been doing a comparison test between the system module with journald and log input, and they report a different amount of messages, there are more entries in the log files than in the journal. I did this test on a fresh Debian 11 VM that uses both: jouranld and traditional log files (via rsyslog):

root@bullseye:/var/log# wc -l syslog auth.log messages 
   679 syslog
   147 auth.log
   423 messages
  1249 total
root@bullseye:/var/log# journalctl --no-tail | wc -l
919
root@bullseye:/var/log# 

The dashboards seem correctly populated (screenshots in the PR description).

I'm still investigating this difference.

so, that means the PR isn't yet ready to be merged, right? We don't wanna it to go in unless we're sure we're not loosing logs.

Perhaps it should go back to draft? What do you think?

@AndersonQ
Copy link
Member

Anyway I'll test it

@AndersonQ
Copy link
Member

Anyway I'll test it

it works. I don't see the map SSH failed login attempts source locations [Filebeat System] ECS populated. @belimawr do you know where the date to populate this map comes from?

@@ -334,6 +334,7 @@ https://github.com/elastic/beats/compare/v8.8.1\...main[Check the HEAD diff]
- Improved Azure Blob Storage input documentation. {pull}41252[41252]
- Make ETW input GA. {pull}41389[41389]
- Add support for Okta entity analytics provider to collect role and factor data for users. {pull}41460[41460]
- Add support for Journald in the System module. {pull}41555[41555]
Copy link
Member

Choose a reason for hiding this comment

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

I'm not sure where it needs to be placed, but if there is a difference between he number of logs collected between journald and the log input it might be good to have it documented somewhere.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

We're already collecting all the journald logs, to me the difference in the number of logs from journald and the files is a OS detail, also some OSes only use jouranld, which makes comparing impossible unless something like rsyslog is installed and setup to generate the log files.

@AndersonQ
Copy link
Member

I've been doing a comparison test between the system module with journald and log input, and they report a different amount of messages, there are more entries in the log files than in the journal. I did this test on a fresh Debian 11 VM that uses both: jouranld and traditional log files (via rsyslog):

root@bullseye:/var/log# wc -l syslog auth.log messages 
   679 syslog
   147 auth.log
   423 messages
  1249 total
root@bullseye:/var/log# journalctl --no-tail | wc -l
919
root@bullseye:/var/log# 

The dashboards seem correctly populated (screenshots in the PR description).
I'm still investigating this difference.

so, that means the PR isn't yet ready to be merged, right? We don't wanna it to go in unless we're sure we're not loosing logs.

Perhaps it should go back to draft? What do you think?

we had a call, the journald input consumes all the logs on journald, so I don't see it as a blocker here

@belimawr
Copy link
Contributor Author

I've been doing a comparison test between the system module with journald and log input, and they report a different amount of messages, there are more entries in the log files than in the journal. I did this test on a fresh Debian 11 VM that uses both: jouranld and traditional log files (via rsyslog):

root@bullseye:/var/log# wc -l syslog auth.log messages 
   679 syslog
   147 auth.log
   423 messages
  1249 total
root@bullseye:/var/log# journalctl --no-tail | wc -l
919
root@bullseye:/var/log# 

The dashboards seem correctly populated (screenshots in the PR description).
I'm still investigating this difference.

so, that means the PR isn't yet ready to be merged, right? We don't wanna it to go in unless we're sure we're not loosing logs.

Perhaps it should go back to draft? What do you think?

It's ready for review. I've investigated more and the system module can ingest without errors all logs in the journal, so any difference in the amount of logs available is at the OS level, outside of the scope of this PR.

If needed, I could dig deeper to understand the difference. Let me know if you, or any other reviewer, believes it's necessary.

Copy link
Member

@AndersonQ AndersonQ 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 https://github.com/elastic/beats/pull/41555/files#r1842419453 as a blocker. We just need to check if we need to add any doc explaining the difference between the log input and journald. Also the whole point is to be able to have the system module on systems where there is only journald, so, again not a blocker

@belimawr
Copy link
Contributor Author

Anyway I'll test it

it works. I don't see the map SSH failed login attempts source locations [Filebeat System] ECS populated. @belimawr do you know where the date to populate this map comes from?

No, I don't.

Copy link
Contributor

mergify bot commented Nov 18, 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 40526-system-module-debian-12-V2 upstream/40526-system-module-debian-12-V2
git merge upstream/main
git push upstream 40526-system-module-debian-12-V2

@belimawr belimawr merged commit f4b80fd into elastic:main Nov 18, 2024
31 checks passed
mergify bot pushed a commit that referenced this pull request Nov 18, 2024
This commit adds journald support for the System module, both filesets now have a `use_journald` variable
that can be set to force using Journald to ingest syslog and auth logs.

The ingest pipelines are updated, now there is an entrypoint pipeline that selects the correct one according to the field
`input.type`.

System tests are also added.

(cherry picked from commit f4b80fd)
pierrehilbert pushed a commit that referenced this pull request Nov 19, 2024
This commit adds journald support for the System module, both filesets now have a `use_journald` variable
that can be set to force using Journald to ingest syslog and auth logs.

The ingest pipelines are updated, now there is an entrypoint pipeline that selects the correct one according to the field
`input.type`.

System tests are also added.

(cherry picked from commit f4b80fd)

Co-authored-by: Tiago Queiroz <[email protected]>
@belimawr belimawr deleted the 40526-system-module-debian-12-V2 branch December 19, 2024 13:56
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 enhancement 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.

Investigate the best way to decide when to read system logs from files or journald
3 participants