Skip to content

Commit

Permalink
Merge branch 'master' of github.com:elastic/beats into fix/invalid-start
Browse files Browse the repository at this point in the history
  • Loading branch information
michalpristas committed Jun 8, 2021
2 parents ae3951d + a3b642b commit 89a1c35
Show file tree
Hide file tree
Showing 47 changed files with 1,318 additions and 990 deletions.
8 changes: 8 additions & 0 deletions CHANGELOG.next.asciidoc
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,7 @@ https://github.com/elastic/beats/compare/v7.0.0-alpha2...master[Check the HEAD d
- Change logging in logs input to structure logging. Some log message formats have changed. {pull}25299[25299]

*Heartbeat*
- Add support for screenshot blocks and use newer synthetics flags that only works in newer synthetics betas. {pull}25808[25808]

*Journalbeat*

Expand Down Expand Up @@ -238,6 +239,8 @@ https://github.com/elastic/beats/compare/v7.0.0-alpha2...master[Check the HEAD d
- Fix 'make setup' instructions for a new beat {pull}24944[24944]
- Fix out of date FreeBSD vagrantbox. {pull}25652[25652]
- Fix handling of `file_selectors` in aws-s3 input. {pull}25792[25792]
- Fix ILM alias creation when write alias exists and initial index does not exist {pull}26143[26143]
- Include date separator in the filename prefix of `dateRotator` to make sure nothing gets purged accidentally {pull}26176[26176]

*Auditbeat*

Expand All @@ -259,6 +262,7 @@ https://github.com/elastic/beats/compare/v7.0.0-alpha2...master[Check the HEAD d
- system/socket: Fixed start failure when run under config reloader. {issue}20851[20851] {pull}21693[21693]
- system/socket: Having some CPUs unavailable to Auditbeat could cause startup errors or event loss. {pull}22827[22827]
- Note incompatibility of system/socket on ARM. {pull}23381[23381]
- auditd: Fix kernel deadlock when netlink congestion causes "no buffer space available" errors. {issue}26031[26031] {pull}26032[26032]

*Filebeat*

Expand Down Expand Up @@ -382,6 +386,7 @@ https://github.com/elastic/beats/compare/v7.0.0-alpha2...master[Check the HEAD d
- Fix `fortinet.firewall.addr` when its a string, not an IP address. {issue}25585[25585] {pull}25608[25608]
- Fix incorrect field name appending to `related.hash` in `threatintel.abusechmalware` ingest pipeline. {issue}25151[25151] {pull}25674[25674]
- Fix `kibana.log` pipeline when `event.duration` calculation becomes a Long. {issue}24556[24556] {pull}25675[25675]
- o365: Avoid mapping exception for `Parameters` and `ExtendedProperties` fields of string type. {pull}26164[26164]

*Heartbeat*

Expand Down Expand Up @@ -808,6 +813,8 @@ https://github.com/elastic/beats/compare/v7.0.0-alpha2...master[Check the HEAD d
- Add fingerprint processor to generate fixed ids for `google_workspace` events. {pull}25841[25841]
- Update PanOS module to parse HIP Match logs. {issue}24350[24350] {pull}25686[25686]
- Enhance GCP module to populate orchestrator.* fields for GKE / K8S logs {pull}25368[25368]
- http_endpoint: Support multiple documents in a single request by POSTing an array or NDJSON format. {pull}25764[25764]
- Make `filestream` input GA. {pull}26127[26127]

*Heartbeat*

Expand Down Expand Up @@ -940,6 +947,7 @@ https://github.com/elastic/beats/compare/v7.0.0-alpha2...master[Check the HEAD d
- Add additional network metrics to docker/network {pull}25354[25354]
- Migrate ec2 metricsets to use cloudwatch input. {pull}25924[25924]
- Reduce number of requests done by kubernetes metricsets to kubelet. {pull}25782[25782]
- Migrate rds metricsets to use cloudwatch input. {pull}26077[26077]
- Migrate sqs metricsets to use cloudwatch input. {pull}26117[26117]

*Packetbeat*
Expand Down
50 changes: 45 additions & 5 deletions auditbeat/module/auditd/audit_linux.go
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,8 @@ const (

lostEventsUpdateInterval = time.Second * 15
maxDefaultStreamBufferConsumers = 4

setPIDMaxRetries = 5
)

type backpressureStrategy uint8
Expand Down Expand Up @@ -137,10 +139,32 @@ func newAuditClient(c *Config, log *logp.Logger) (*libaudit.AuditClient, error)
return libaudit.NewAuditClient(nil)
}

func closeAuditClient(client *libaudit.AuditClient) error {
discard := func(bytes []byte) ([]syscall.NetlinkMessage, error) {
return nil, nil
}
// Drain the netlink channel in parallel to Close() to prevent a deadlock.
// This goroutine will terminate once receive from netlink errors (EBADF,
// EBADFD, or any other error). This happens because the fd is closed.
go func() {
for {
_, err := client.Netlink.Receive(true, discard)
switch err {
case nil, syscall.EINTR:
case syscall.EAGAIN:
time.Sleep(50 * time.Millisecond)
default:
return
}
}
}()
return client.Close()
}

// Run initializes the audit client and receives audit messages from the
// kernel until the reporter's done channel is closed.
func (ms *MetricSet) Run(reporter mb.PushReporterV2) {
defer ms.client.Close()
defer closeAuditClient(ms.client)

if err := ms.addRules(reporter); err != nil {
reporter.Error(err)
Expand All @@ -164,7 +188,7 @@ func (ms *MetricSet) Run(reporter mb.PushReporterV2) {
go func() {
defer func() { // Close the most recently allocated "client" instance.
if client != nil {
client.Close()
closeAuditClient(client)
}
}()
timer := time.NewTicker(lostEventsUpdateInterval)
Expand All @@ -178,7 +202,7 @@ func (ms *MetricSet) Run(reporter mb.PushReporterV2) {
ms.updateKernelLostMetric(status.Lost)
} else {
ms.log.Error("get status request failed:", err)
if err = client.Close(); err != nil {
if err = closeAuditClient(client); err != nil {
ms.log.Errorw("Error closing audit monitoring client", "error", err)
}
client, err = libaudit.NewAuditClient(nil)
Expand Down Expand Up @@ -233,7 +257,7 @@ func (ms *MetricSet) addRules(reporter mb.PushReporterV2) error {
if err != nil {
return errors.Wrap(err, "failed to create audit client for adding rules")
}
defer client.Close()
defer closeAuditClient(client)

// Don't attempt to change configuration if audit rules are locked (enabled == 2).
// Will result in EPERM.
Expand Down Expand Up @@ -350,10 +374,12 @@ func (ms *MetricSet) initClient() error {
return errors.Wrap(err, "failed to enable auditing in the kernel")
}
}

if err := ms.client.WaitForPendingACKs(); err != nil {
return errors.Wrap(err, "failed to wait for ACKs")
}
if err := ms.client.SetPID(libaudit.WaitForReply); err != nil {

if err := ms.setPID(setPIDMaxRetries); err != nil {
if errno, ok := err.(syscall.Errno); ok && errno == syscall.EEXIST && status.PID != 0 {
return fmt.Errorf("failed to set audit PID. An audit process is already running (PID %d)", status.PID)
}
Expand All @@ -362,6 +388,20 @@ func (ms *MetricSet) initClient() error {
return nil
}

func (ms *MetricSet) setPID(retries int) (err error) {
if err = ms.client.SetPID(libaudit.WaitForReply); err == nil || errors.Cause(err) != syscall.ENOBUFS || retries == 0 {
return err
}
// At this point the netlink channel is congested (ENOBUFS).
// Drain and close the client, then retry with a new client.
closeAuditClient(ms.client)
if ms.client, err = newAuditClient(&ms.config, ms.log); err != nil {
return errors.Wrapf(err, "failed to recover from ENOBUFS")
}
ms.log.Info("Recovering from ENOBUFS ...")
return ms.setPID(retries - 1)
}

func (ms *MetricSet) updateKernelLostMetric(lost uint32) {
if !ms.kernelLost.enabled {
return
Expand Down
2 changes: 1 addition & 1 deletion filebeat/_meta/config/filebeat.inputs.reference.yml.tmpl
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ filebeat.inputs:
#
# Possible options are:
# * log: Reads every line of the log file (default)
# * filestream: Improved version of log input. Experimental.
# * filestream: Improved version of log input
# * stdin: Reads the standard in

#------------------------------ Log input --------------------------------
Expand Down
2 changes: 1 addition & 1 deletion filebeat/_meta/config/filebeat.inputs.yml.tmpl
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ filebeat.inputs:
# Note: After is the equivalent to previous and before is the equivalent to to next in Logstash
#multiline.match: after

# filestream is an experimental input. It is going to replace log input in the future.
# filestream is an input for collecting log messages from files. It is going to replace log input in the future.
- type: filestream

# Change to true to enable this input configuration.
Expand Down
2 changes: 0 additions & 2 deletions filebeat/docs/inputs/input-filestream.asciidoc
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,6 @@
[id="{beatname_lc}-input-{type}"]
=== filestream input

beta[]

++++
<titleabbrev>filestream</titleabbrev>
++++
Expand Down
2 changes: 1 addition & 1 deletion filebeat/filebeat.reference.yml
Original file line number Diff line number Diff line change
Expand Up @@ -418,7 +418,7 @@ filebeat.inputs:
#
# Possible options are:
# * log: Reads every line of the log file (default)
# * filestream: Improved version of log input. Experimental.
# * filestream: Improved version of log input
# * stdin: Reads the standard in

#------------------------------ Log input --------------------------------
Expand Down
2 changes: 1 addition & 1 deletion filebeat/filebeat.yml
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ filebeat.inputs:
# Note: After is the equivalent to previous and before is the equivalent to to next in Logstash
#multiline.match: after

# filestream is an experimental input. It is going to replace log input in the future.
# filestream is an input for collecting log messages from files. It is going to replace log input in the future.
- type: filestream

# Change to true to enable this input configuration.
Expand Down
2 changes: 1 addition & 1 deletion filebeat/input/filestream/input.go
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ type filestream struct {
func Plugin(log *logp.Logger, store loginp.StateStore) input.Plugin {
return input.Plugin{
Name: pluginName,
Stability: feature.Beta,
Stability: feature.Stable,
Deprecated: false,
Info: "filestream input",
Doc: "The filestream input collects logs from the local filestream service",
Expand Down
75 changes: 69 additions & 6 deletions heartbeat/_meta/fields.common.yml
Original file line number Diff line number Diff line change
Expand Up @@ -174,6 +174,69 @@
type: text
- name: stack
type: text
- name: screenshot_ref
type: group
dynamic: false
fields:
- name: width
type: integer
description: Width of the full screenshot in pixels.
- name: height
type: integer
description: Height of the full screenshot in pixels
- name: blocks
type: group
description: Attributes representing individual screenshot blocks. Only hash is indexed since it's the only one we'd query on.
fields:
- name: hash
type: keyword
description: Hash that uniquely identifies this image by content. Corresponds to block document id.
- name: browser
type: group
fields:
- name: experience
type: group
fields:
- name: name
type: keyword
- name: type
type: text
description: >
denotes the 'mark' event
- name: start
type: long
description: >
offset of time relative to journey start in milliseconds
- name: user_timing
type: group
fields:
- name: name
type: keyword
- name: type
type: text
description: >
could be one of mark or measure event types.
- name: start
type: long
description: >
offset of time relative to journey start in milliseconds
- name: end
type: long
description: >
offset of time relative to journey start in milliseconds
- name: layout_shift
type: group
fields:
- name: name
type: keyword
- name: score
type: integer
- name: exists
type: boolean
description: >
flag that indicates if there was any layout shift events
present on the page.
- key: http
title: "HTTP monitor"
description:
Expand Down Expand Up @@ -379,12 +442,12 @@
type: group
description: Detailed x509 certificate metadata
fields:
- name: version_number
type: keyword
ignore_above: 1024
description: Version of x509 format.
example: 3
default_field: false
- name: version_number
type: keyword
ignore_above: 1024
description: Version of x509 format.
example: 3
default_field: false

- key: icmp
title: "ICMP"
Expand Down
Loading

0 comments on commit 89a1c35

Please sign in to comment.