-
Notifications
You must be signed in to change notification settings - Fork 4.9k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add skeleton x-pack Auditbeat module (#8252)
This adds an skeleton x-pack module to Auditbeat. The module is only included in the Elastic licensed Auditbeat binary. The config and fields.yml data are not yet included in the packaging. Additional updates are required.
- Loading branch information
1 parent
06ae246
commit 4bd1205
Showing
13 changed files
with
160 additions
and
4 deletions.
There are no files selected for viewing
This file contains 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
This file contains 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
This file contains 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
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains 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
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
// Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one | ||
// or more contributor license agreements. Licensed under the Elastic License; | ||
// you may not use this file except in compliance with the Elastic License. | ||
|
||
package include | ||
|
||
import ( | ||
// Include all Auditbeat modules so that they register their | ||
// factories with the global registry. | ||
_ "github.com/elastic/beats/x-pack/auditbeat/module/sysinfo/host" | ||
) |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
{{ if .Reference -}} | ||
{{ end -}} | ||
- module: sysinfo | ||
{{ if eq .GOOS "darwin" -}} | ||
metricsets: | ||
- host | ||
{{ else if eq .GOOS "windows" -}} | ||
metricsets: | ||
- host | ||
{{ else -}} | ||
metricsets: | ||
- host | ||
{{- end }} | ||
{{ if .Reference }} | ||
{{- end }} |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
== Sysinfo Module | ||
|
||
The `sysinfo` module ... TODO. | ||
|
||
The module is implemented for Linux, macOS (Darwin), and Windows. | ||
|
||
[float] | ||
=== How it works | ||
|
||
TODO | ||
|
||
[float] | ||
=== Configuration options | ||
|
||
TODO | ||
|
||
[source,yaml] | ||
---- | ||
- module: sysinfo | ||
---- | ||
|
||
*`some_option`*:: TODO |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
- key: sysinfo | ||
title: Sysinfo | ||
description: These are the fields generated by the sysinfo module. | ||
fields: |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
The Sysinfo `host` metricset provides ... TODO. | ||
|
||
The module is implemented for Linux, macOS (Darwin), and Windows. | ||
|
||
[float] | ||
=== Configuration options | ||
|
||
TODO |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
- name: host | ||
type: group | ||
description: > | ||
`host` contains TODO. | ||
release: experimental | ||
fields: |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
// Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one | ||
// or more contributor license agreements. Licensed under the Elastic License; | ||
// you may not use this file except in compliance with the Elastic License. | ||
|
||
package host | ||
|
||
// Config defines the host metricset's configuration options. | ||
type Config struct { | ||
// TODO: Add config options. | ||
} | ||
|
||
// Validate validates the host metricset config. | ||
func (c *Config) Validate() error { | ||
return nil | ||
} | ||
|
||
var defaultConfig = Config{} |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
// Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one | ||
// or more contributor license agreements. Licensed under the Elastic License; | ||
// you may not use this file except in compliance with the Elastic License. | ||
|
||
package host | ||
|
||
import ( | ||
"github.com/pkg/errors" | ||
|
||
"github.com/elastic/beats/libbeat/common" | ||
"github.com/elastic/beats/libbeat/common/cfgwarn" | ||
"github.com/elastic/beats/metricbeat/mb" | ||
) | ||
|
||
const ( | ||
moduleName = "sysinfo" | ||
metricsetName = "host" | ||
) | ||
|
||
func init() { | ||
mb.Registry.MustAddMetricSet(moduleName, metricsetName, New, | ||
mb.DefaultMetricSet(), | ||
) | ||
} | ||
|
||
// MetricSet collects data about the host. | ||
type MetricSet struct { | ||
mb.BaseMetricSet | ||
} | ||
|
||
// New constructs a new MetricSet. | ||
func New(base mb.BaseMetricSet) (mb.MetricSet, error) { | ||
cfgwarn.Experimental("The %v/%v dataset is experimental", moduleName, metricsetName) | ||
|
||
config := defaultConfig | ||
if err := base.Module().UnpackConfig(&config); err != nil { | ||
return nil, errors.Wrapf(err, "failed to unpack the %v/%v config", moduleName, metricsetName) | ||
} | ||
|
||
return &MetricSet{base}, nil | ||
} | ||
|
||
// Fetch collects data about the host. It is invoked periodically. | ||
func (ms *MetricSet) Fetch(report mb.ReporterV2) { | ||
report.Event(mb.Event{ | ||
RootFields: common.MapStr{ | ||
"hello": "world", | ||
}, | ||
}) | ||
} |