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

[8.6](backport #34246) Osquerybeat: Fix data_stream configuration, enforce the default values used before 8.6.0 #34262

Merged
merged 1 commit into from
Jan 14, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions CHANGELOG.next.asciidoc
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,10 @@ https://github.com/elastic/beats/compare/v8.2.0\...main[Check the HEAD diff]
- Support Oracle-specific connection strings in SQL module {issue}32089[32089] {pull}32293[32293]
- Remove deprecated metrics from controller manager, scheduler and proxy {pull}34161[34161]

*Osquerybeat*

- Fix data_stream configuration, enforce the default values used before 8.6.0. {pull}34246[34246]

*Packetbeat*


Expand Down
19 changes: 18 additions & 1 deletion x-pack/osquerybeat/cmd/root.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
)

Expand Down Expand Up @@ -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()

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)
Expand Down