-
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
Osquerybeat: Fix data_stream configuration, enforce the default values used before 8.6.0 #34246
Changes from 2 commits
ab9c374
9b0d02d
b8ef343
3ec07bb
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change | ||||||
---|---|---|---|---|---|---|---|---|
|
@@ -23,6 +23,7 @@ import ( | |||||||
|
||||||||
_ "github.com/elastic/beats/v7/x-pack/libbeat/include" | ||||||||
"github.com/elastic/beats/v7/x-pack/osquerybeat/beater" | ||||||||
"github.com/elastic/beats/v7/x-pack/osquerybeat/internal/config" | ||||||||
"github.com/elastic/beats/v7/x-pack/osquerybeat/internal/install" | ||||||||
) | ||||||||
|
||||||||
|
@@ -74,14 +75,30 @@ func genVerifyCmd(_ instance.Settings) *cobra.Command { | |||||||
func osquerybeatCfg(rawIn *proto.UnitExpectedConfig, agentInfo *client.AgentInfo) ([]*reload.ConfigWithMeta, error) { | ||||||||
// Convert to streams, osquerybeat doesn't use streams | ||||||||
streams := make([]*proto.Stream, 1) | ||||||||
|
||||||||
// Enforce the datastream dataset and type because the libbeat call to CreateInputsFromStreams | ||||||||
// provides it's own defaults that are breaking the osquery with logstash | ||||||||
// The target datastream for the publisher is expected to be logs-osquery_manager.result-<namespace> | ||||||||
// while the libebeat management.CreateInputsFromStreams defaults to osquery-generic-default | ||||||||
var datastream *proto.DataStream | ||||||||
if rawIn.GetDataStream() != nil { | ||||||||
// Copy by value and modify dataset and type | ||||||||
ds := *rawIn.GetDataStream() | ||||||||
ds.Dataset = config.DefaultDataset | ||||||||
ds.Type = config.DefaultType | ||||||||
datastream = &ds | ||||||||
} | ||||||||
|
||||||||
streams[0] = &proto.Stream{ | ||||||||
Source: rawIn.GetSource(), | ||||||||
Id: rawIn.GetId(), | ||||||||
DataStream: rawIn.GetDataStream(), | ||||||||
DataStream: datastream, | ||||||||
} | ||||||||
|
||||||||
rawIn.Streams = streams | ||||||||
|
||||||||
procs := defaultProcessors() | ||||||||
|
||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I can't comment directly on this, but this block below can be removed: beats/x-pack/osquerybeat/cmd/root.go Lines 89 to 91 in b5246c4
That is trying to set an input type, which I don't think matters for osquerybeat. It is just adding an arbitrary There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. yeah, don't remember the reason for this. can clean up later, separately from this more urgent fix There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think it is a copy/paste error from one of the other Beats, agree this can be removed separately. |
||||||||
modules, err := management.CreateInputsFromStreams(rawIn, "osquery", agentInfo, procs...) | ||||||||
if err != nil { | ||||||||
return nil, fmt.Errorf("error creating input list from raw expected config: %w", err) | ||||||||
|
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.
This works, but if the dataset or type ever becomes configurable it will break. That's probably unlikely though.