Skip to content
Closed
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
1 change: 1 addition & 0 deletions CHANGELOG.asciidoc
Original file line number Diff line number Diff line change
Expand Up @@ -121,6 +121,7 @@ https://github.com/elastic/beats/compare/v6.4.0...master[Check the HEAD diff]
- Add tag "multiline" to "log.flags" if event consists of multiple lines. {pull}7997[7997]
- Add haproxy module. {pull}8014[8014]
- Release `docker` input as GA. {pull}8328[8328]
- Keep original messages in case of Filebeat modules. {pull}8448[8448]

*Heartbeat*

Expand Down
6 changes: 6 additions & 0 deletions filebeat/_meta/fields.common.yml
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,12 @@
description: >
This field contains the flags of the event.

- name: log.original
type: keyword
description: >
The unprocessed original log message. This can be used for reprocessing logs.
index: false

- name: event.created
type: date
description: >
Expand Down
27 changes: 19 additions & 8 deletions filebeat/channel/factory.go
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,9 @@ type clientEventer struct {
// inputOutletConfig defines common input settings
// for the publisher pipeline.
type inputOutletConfig struct {
// KeepOriginalMsg determines if the original message needs to be kept for a module.
KeepOriginalMsg bool `config:"keep_original_message"`

// event processing
common.EventMetadata `config:",inline"` // Fields and tags to add to events.
Processors processors.PluginConfig `config:"processors"`
Expand All @@ -59,6 +62,10 @@ type inputOutletConfig struct {

}

var defaultConfig = inputOutletConfig{
KeepOriginalMsg: true,
}

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 strongly believe this should be a opt-in feature.

// NewOutletFactory creates a new outlet factory for
// connecting an input to the publisher pipeline.
func NewOutletFactory(
Expand All @@ -82,7 +89,7 @@ func NewOutletFactory(
// This guarantees ordering between events as required by the registrar for
// file.State updates
func (f *OutletFactory) Create(p beat.Pipeline, cfg *common.Config, dynFields *common.MapStrPointer) (Outleter, error) {
config := inputOutletConfig{}
config := defaultConfig
if err := cfg.Unpack(&config); err != nil {
return nil, err
}
Expand All @@ -101,13 +108,16 @@ func (f *OutletFactory) Create(p beat.Pipeline, cfg *common.Config, dynFields *c
meta := common.MapStr{}
setMeta(meta, "pipeline", config.Pipeline)

keepOriginal := false
fields := common.MapStr{}
setMeta(fields, "module", config.Module)
setMeta(fields, "name", config.Fileset)
if len(fields) > 0 {
fields = common.MapStr{
"fileset": fields,
}
keepOriginal = config.KeepOriginalMsg

}
if config.Type != "" {
fields["prospector"] = common.MapStr{
Expand All @@ -119,13 +129,14 @@ func (f *OutletFactory) Create(p beat.Pipeline, cfg *common.Config, dynFields *c
}

client, err := p.ConnectWith(beat.ClientConfig{
PublishMode: beat.GuaranteedSend,
EventMetadata: config.EventMetadata,
DynamicFields: dynFields,
Meta: meta,
Fields: fields,
Processor: processors,
Events: f.eventer,
PublishMode: beat.GuaranteedSend,
EventMetadata: config.EventMetadata,
DynamicFields: dynFields,
Meta: meta,
Fields: fields,
KeepOriginalMsg: keepOriginal,
Processor: processors,
Events: f.eventer,
})
if err != nil {
return nil, err
Expand Down
12 changes: 12 additions & 0 deletions filebeat/docs/fields.asciidoc
Original file line number Diff line number Diff line change
Expand Up @@ -3042,6 +3042,18 @@ Logging level.
This field contains the flags of the event.


--

*`log.original`*::
+
--
type: keyword

The unprocessed original log message. This can be used for reprocessing logs.


Field is not indexed.

--

*`event.created`*::
Expand Down
34 changes: 34 additions & 0 deletions filebeat/filebeat.reference.yml
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,8 @@ filebeat.modules:
# Input configuration (advanced). Any input configuration option
# can be added under this section.
#input:
#Keeps the original message, so the data can be processed again on Ingest Node.
#keep_original_message: true

# Authorization logs
#auth:
Expand All @@ -42,6 +44,8 @@ filebeat.modules:
# Input configuration (advanced). Any input configuration option
# can be added under this section.
#input:
#Keeps the original message, so the data can be processed again on Ingest Node.
#keep_original_message: true

#------------------------------- Apache2 Module ------------------------------
#- module: apache2
Expand All @@ -56,6 +60,8 @@ filebeat.modules:
# Input configuration (advanced). Any input configuration option
# can be added under this section.
#input:
#Keeps the original message, so the data can be processed again on Ingest Node.
#keep_original_message: true

# Error logs
#error:
Expand All @@ -68,6 +74,8 @@ filebeat.modules:
# Input configuration (advanced). Any input configuration option
# can be added under this section.
#input:
#Keeps the original message, so the data can be processed again on Ingest Node.
#keep_original_message: true

#------------------------------- Auditd Module -------------------------------
#- module: auditd
Expand All @@ -81,6 +89,8 @@ filebeat.modules:
# Input configuration (advanced). Any input configuration option
# can be added under this section.
#input:
#Keeps the original message, so the data can be processed again on Ingest Node.
#keep_original_message: true

#---------------------------- elasticsearch Module ---------------------------
- module: elasticsearch
Expand Down Expand Up @@ -142,6 +152,8 @@ filebeat.modules:
# Input configuration (advanced). Any input configuration option
# can be added under this section.
#input:
#Keeps the original message, so the data can be processed again on Ingest Node.
#keep_original_message: true

# Debug logs
#debug:
Expand All @@ -154,6 +166,8 @@ filebeat.modules:
# Input configuration (advanced). Any input configuration option
# can be added under this section.
#input:
#Keeps the original message, so the data can be processed again on Ingest Node.
#keep_original_message: true

# Startup logs
#startup:
Expand All @@ -166,6 +180,8 @@ filebeat.modules:
# Input configuration (advanced). Any input configuration option
# can be added under this section.
#input:
#Keeps the original message, so the data can be processed again on Ingest Node.
#keep_original_message: true

#--------------------------------- IIS Module --------------------------------
#- module: iis
Expand All @@ -180,6 +196,8 @@ filebeat.modules:
# Input configuration (advanced). Any input configuration option
# can be added under this section.
#input:
#Keeps the original message, so the data can be processed again on Ingest Node.
#keep_original_message: true

# Error logs
#error:
Expand All @@ -192,6 +210,8 @@ filebeat.modules:
# Input configuration (advanced). Any input configuration option
# can be added under this section.
#input:
#Keeps the original message, so the data can be processed again on Ingest Node.
#keep_original_message: true

#-------------------------------- Kafka Module -------------------------------
- module: kafka
Expand Down Expand Up @@ -250,6 +270,8 @@ filebeat.modules:
# Input configuration (advanced). Any input configuration option
# can be added under this section.
#input:
#Keeps the original message, so the data can be processed again on Ingest Node.
#keep_original_message: true

#-------------------------------- MySQL Module -------------------------------
#- module: mysql
Expand All @@ -264,6 +286,8 @@ filebeat.modules:
# Input configuration (advanced). Any input configuration option
# can be added under this section.
#input:
#Keeps the original message, so the data can be processed again on Ingest Node.
#keep_original_message: true

# Slow logs
#slowlog:
Expand All @@ -276,6 +300,8 @@ filebeat.modules:
# Input configuration (advanced). Any input configuration option
# can be added under this section.
#input:
#Keeps the original message, so the data can be processed again on Ingest Node.
#keep_original_message: true

#-------------------------------- Nginx Module -------------------------------
#- module: nginx
Expand All @@ -290,6 +316,8 @@ filebeat.modules:
# Input configuration (advanced). Any input configuration option
# can be added under this section.
#input:
#Keeps the original message, so the data can be processed again on Ingest Node.
#keep_original_message: true

# Error logs
#error:
Expand All @@ -302,6 +330,8 @@ filebeat.modules:
# Input configuration (advanced). Any input configuration option
# can be added under this section.
#input:
#Keeps the original message, so the data can be processed again on Ingest Node.
#keep_original_message: true

#------------------------------- Osquery Module ------------------------------
- module: osquery
Expand Down Expand Up @@ -330,6 +360,8 @@ filebeat.modules:
# Input configuration (advanced). Any input configuration option
# can be added under this section.
#input:
#Keeps the original message, so the data can be processed again on Ingest Node.
#keep_original_message: true

#-------------------------------- Redis Module -------------------------------
#- module: redis
Expand Down Expand Up @@ -364,6 +396,8 @@ filebeat.modules:
# Input configuration (advanced). Any input configuration option
# can be added under this section.
#input:
#Keeps the original message, so the data can be processed again on Ingest Node.
#keep_original_message: true


#=========================== Filebeat inputs =============================
Expand Down
Loading