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

First pass at auditbeat support #33026

Merged
Show file tree
Hide file tree
Changes from 2 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
38 changes: 38 additions & 0 deletions x-pack/auditbeat/cmd/agent.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
// Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
fearful-symmetry marked this conversation as resolved.
Show resolved Hide resolved
// or more contributor license agreements. Licensed under the Elastic License;
// you may not use this file except in compliance with the Elastic License.

package cmd

import (
"fmt"
"strings"

"github.com/elastic/beats/v7/libbeat/common/reload"
"github.com/elastic/beats/v7/x-pack/libbeat/management"
"github.com/elastic/elastic-agent-client/v7/pkg/client"
"github.com/elastic/elastic-agent-client/v7/pkg/proto"
)

func auditbeatCfg(rawIn *proto.UnitExpectedConfig, agentInfo *client.AgentInfo) ([]*reload.ConfigWithMeta, error) {
fearful-symmetry marked this conversation as resolved.
Show resolved Hide resolved
modules, err := management.CreateInputsFromStreams(rawIn, "metrics", agentInfo)
if err != nil {
return nil, fmt.Errorf("error creating input list from raw expected config: %w", err)
}

// Extact the type field that has "audit/auditd", treat this
// as the module config key
fearful-symmetry marked this conversation as resolved.
Show resolved Hide resolved
module := strings.Split(rawIn.Type, "/")[1]

for iter := range modules {
modules[iter]["module"] = module
}

// format for the reloadable list needed bythe cm.Reload() method
fearful-symmetry marked this conversation as resolved.
Show resolved Hide resolved
configList, err := management.CreateReloadConfigFromInputs(modules)
if err != nil {
return nil, fmt.Errorf("error creating reloader config: %w", err)
}

return configList, nil
}
2 changes: 2 additions & 0 deletions x-pack/auditbeat/cmd/root.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import (
// Register Auditbeat x-pack modules.
_ "github.com/elastic/beats/v7/x-pack/auditbeat/include"
_ "github.com/elastic/beats/v7/x-pack/libbeat/include"
"github.com/elastic/beats/v7/x-pack/libbeat/management"
fearful-symmetry marked this conversation as resolved.
Show resolved Hide resolved
)

// Name of the beat
Expand All @@ -20,6 +21,7 @@ var Name = auditbeatcmd.Name
var RootCmd *cmd.BeatsRootCmd

func init() {
management.ConfigTransform.SetTransform(auditbeatCfg)
settings := auditbeatcmd.AuditbeatSettings()
settings.ElasticLicensed = true
RootCmd = auditbeatcmd.Initialize(settings)
Expand Down