-
Notifications
You must be signed in to change notification settings - Fork 5k
Add skeleton x-pack Auditbeat module #8252
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Large diffs are not rendered by default.
| 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" | ||
| ) |
| 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 }} |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,22 @@ | ||
| == Sysinfo Module | ||
|
|
||
| The `sysinfo` module ... TODO. | ||
|
Contributor
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 was thinking to name it
Member
Author
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 would be OK to call it "system" if we avoid creating "metricsets" that have the same name as the existing ones in Metricbeat. We use nearly the exact same config between Auditbeat and Metricbeat so calling it the same thing could be confusing (even to us if we just glance at a config), but with unique names then it should be clear.
Member
Author
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 propose we merge it as is and let the module devs take ownership of naming.
Contributor
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. Agreed |
||
|
|
||
| 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 | ||
| 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: |
| 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 |
| 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: |
| 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{} |
| 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", | ||
| }, | ||
| }) | ||
| } |
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.
Interesting. Lets discuss this in an other thread.