-
Notifications
You must be signed in to change notification settings - Fork 4.9k
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
[Auditbeat] Update host metricset #9421
Conversation
Pinging @elastic/secops |
mapstr.Delete("uptime") | ||
mapstr.Delete("boottime") | ||
h.WriteString(host.info.Timezone) | ||
h.WriteString(strconv.Itoa(host.info.TimezoneOffsetSec)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Rather than converting the number to a string (which requires allocation) I think you can use
binary.Write(h, binary.BigEndian, int32(host.Info.TimezoneOffsetSec))
which will write the bytes directly into the hash. It should not fallback to reflection if you cast from int
to int32
(or any sized integer type).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Makes sense. Does it matter if it writes big-endian or little-endian? I see us using both quite heavily in the Beats code.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Endian doesn’t matter. It only matters that it’s hard-coded so that the hash doesn’t change between architectures.
"github.com/elastic/go-sysinfo" | ||
"github.com/elastic/go-sysinfo/types" | ||
) | ||
|
||
const ( | ||
moduleName = "system" | ||
metricsetName = "host" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@andrewkroh @tsg Should this be audit.host
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm planning to rename the module in a separate PR.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Got it, so the module name will be system.audit?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I was planning to namespace the fields only:
func init() {
mb.Registry.MustAddMetricSet(moduleName, metricsetName, New,
mb.DefaultMetricSet(),
mb.WithNamespace("system.audit")
)
}
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
With #9393 it will become important that event.dataset
is unique, meaning it should be system.audit.process
here. Let's see what tricks we can apply here.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
+1 on getting the PR in and then as soon as #9393 is also merged, will figure it out.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I see how having data from two different metricsets having the same event.dataset
can be confusing. But I don't think that is different from having the same event.module
and event.metricset
.
Still, I could see value in having unique dataset names. Who knows, maybe sometime in the future we might have only datasets, and no more modules/metricsets.
I opened #9499 for namespacing the system module, we can discuss any changes there.
Updates the `host` metricset to be in line with the other metricsets in the `system` module: 1. Adds regular state reporting based on `state.period`/`host.state.period` 2. Persists state between restarts in `beat.db` 3. Detects changes in host information 4. Changes to using `system.host.ip`/`system.host.mac` instead of `system.host.network.interfaces`
Similar to #9139, this updates the
host
metricset to be in line with the other metricsets in thesystem
module.High-level changes:
state.period
/host.state.period
beat.db
event.action
:3.1
host_id_changed
(whensystem.host.id
changes)3.2
reboot
(whensystem.host.boottime
changes)3.3
host_changed
(for all other changes, e.g. hostname, IPs)system.host.ip
/system.host.mac
instead ofsystem.host.network.interfaces
- theadd_host_metadata
processor reports IPs and MACs only, too, and I don't see value at the moment of reporting the full network information. We can always add it later.In contrast to the other metricsets, this one maintains its own
system.host
namespace instead of using the top-levelhost
. This is becausehost
is filled by theadd_host_metadata
processor. The processor uses cached values, and so a change event would be accompanied by unchanged data.