Skip to content
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 auditbeat/_meta/fields.common.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,10 @@
description: >
The name of the module that generated the event.

- name: event.dataset
description: >
The name of the module's dataset that generated the event.

- name: event.action
type: keyword
example: logged-in
Expand Down
6 changes: 6 additions & 0 deletions auditbeat/core/eventmod.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,4 +30,10 @@ func AddDatasetToEvent(module, metricSet string, event *mb.Event) {
}

event.RootFields.Put("event.module", module)

// Modules without "datasets" should set their module and metricset names
// to the same value then this will omit the event.dataset field.
if module != metricSet {
Copy link
Copy Markdown
Contributor

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.

event.RootFields.Put("event.dataset", metricSet)
}
}
8 changes: 8 additions & 0 deletions auditbeat/docs/fields.asciidoc
Original file line number Diff line number Diff line change
Expand Up @@ -2759,6 +2759,14 @@ Contains common fields available in all event types.
The name of the module that generated the event.


--

*`event.dataset`*::
+
--
The name of the module's dataset that generated the event.


--

*`event.action`*::
Expand Down
2 changes: 1 addition & 1 deletion auditbeat/include/fields.go

Large diffs are not rendered by default.

11 changes: 8 additions & 3 deletions x-pack/auditbeat/cmd/root.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,16 @@

package cmd

import "github.com/elastic/beats/auditbeat/cmd"
import (
"github.com/elastic/beats/auditbeat/cmd"

// RootCmd to handle beats cli
// Register Auditbeat x-pack modules.
_ "github.com/elastic/beats/x-pack/auditbeat/include"
)

// RootCmd to handle beats CLI.
var RootCmd = cmd.RootCmd

func init() {
// TODO inject x-pack features
// TODO: Inject x-pack features.
}
11 changes: 11 additions & 0 deletions x-pack/auditbeat/include/list.go
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"
)
15 changes: 15 additions & 0 deletions x-pack/auditbeat/module/sysinfo/_meta/config.yml.tmpl
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 }}
22 changes: 22 additions & 0 deletions x-pack/auditbeat/module/sysinfo/_meta/docs.asciidoc
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
== Sysinfo Module

The `sysinfo` module ... TODO.
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I was thinking to name it system to follow the Metricbeat and Filebeat tradition, but maybe that creates more confusion? I’m not sure.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The 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.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The 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.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The 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
4 changes: 4 additions & 0 deletions x-pack/auditbeat/module/sysinfo/_meta/fields.yml
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:
8 changes: 8 additions & 0 deletions x-pack/auditbeat/module/sysinfo/host/_meta/docs.asciidoc
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
6 changes: 6 additions & 0 deletions x-pack/auditbeat/module/sysinfo/host/_meta/fields.yml
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:
17 changes: 17 additions & 0 deletions x-pack/auditbeat/module/sysinfo/host/config.go
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{}
50 changes: 50 additions & 0 deletions x-pack/auditbeat/module/sysinfo/host/host.go
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",
},
})
}