[Auditbeat] Cherry-pick #9327 to 6.x: Login metricset#10509
Merged
cwurm merged 5 commits intoelastic:6.xfrom Feb 4, 2019
Merged
[Auditbeat] Cherry-pick #9327 to 6.x: Login metricset#10509cwurm merged 5 commits intoelastic:6.xfrom
cwurm merged 5 commits intoelastic:6.xfrom
Conversation
Adds the login metricset to the Auditbeat system module as the last of the six initial metricsets. It only works on Linux, and detects not just user logins and logouts, but also system boots and shutdowns. It works by reading the /var/log/wtmp and /var/log/btmp file (and rotated files) present on Linux systems. In reading a file, it is similar to Filebeat, except that UTMP is a binary format, so reading happens using a binary Go reader. (cherry picked from commit 1566e66)
houndci-bot
reviewed
Feb 3, 2019
Contributor
|
Pinging @elastic/secops |
houndci-bot
reviewed
Feb 3, 2019
Contributor
Author
|
I pushed two changes:
|
andrewkroh
approved these changes
Feb 4, 2019
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Cherry-pick of PR #9327 to 6.x branch. Original message:
This adds the
loginmetricset to the Auditbeat system module. It's the last of the six initial metricsets. It only works on Linux, and detects not just user logins and logouts, but also system boots and shutdowns.It works by reading the
/var/log/wtmpand/var/log/btmpfile (and rotated files) present on Linux systems. In reading a file, it is similar to Filebeat, except that UTMP is a binary format, so reading happens using a binary Go reader. See utmp(5) for the format of that file.The logic is roughly as follows:
login.utmp_file_patternandlogin.btmp_file_patternwill contain the pattern matching the wtmp (good logins, as well as system shutdowns and boots) and btmp (bad/failed logins) files and rotated files (if desired). The defaults are/var/log/wtmp*and/var/log/btmp*. These are expanded usingfilepath.Globand the files are sorted lexicographically in reverse order (i.e./var/log/wtmp.1will come before/var/log/wtmp) so that we read older login records first - reading in order is required for matching login and logout records, see next steps.Fetchit checks for new entries: Any new files are read from the beginning, while known files are read from a saved offset. To that purpose, the last offset per file is saved and persisted to disk inbeat.db. A new file is one that has an unknown inode, but files are also read completely if theirnewSize < oldSizefor some reason (that should make it work with any potential inode reuse - very unlikely since this will never read a lot of files but still possible).LoginRecordin the code). Boot and shutdown events are fairly straightforward, user login and logout events have to be matched using theirtty- so there is aloginSessionsmap that stores logins to enrich the logouts, and is also persisted to disk.Note: This dataset also introduces
event.origincontaining the file the event came from, e.g./var/log/wtmp.1. In other cases, it would be something likeprocfsornetlink. It's useful to know where information comes from, e.g. to know how reliable it is.