Skip to content

Commit

Permalink
Add host.name in the events
Browse files Browse the repository at this point in the history
As a solution for elastic#7050, we adding a `host.name` field to
all events. This is duplicate information from `beat.name`,
but is used to avoid the mapping conflict and to slowly
introduce the "host as an object" approach.

To remove the duplication, you can remove `beat.name` like this:

    processors:
      - drop_fields.fields: ["beat.name"]

Closes elastic#7050.
  • Loading branch information
tsg committed May 9, 2018
1 parent 9306c09 commit 2cca46e
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 1 deletion.
3 changes: 3 additions & 0 deletions libbeat/publisher/pipeline/module.go
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,9 @@ func Load(
"hostname": beatInfo.Hostname,
"version": beatInfo.Version,
},
Host: common.MapStr{
"name": name,
},
},
}

Expand Down
6 changes: 6 additions & 0 deletions libbeat/publisher/pipeline/pipeline.go
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,7 @@ type pipelineProcessors struct {
// constructing the clients complete processor
// pipeline on connect.
beatsMeta common.MapStr
hostMeta common.MapStr
fields common.MapStr
tags []string

Expand Down Expand Up @@ -93,6 +94,7 @@ type Settings struct {
type Annotations struct {
Beat common.MapStr
Event common.EventMetadata
Host common.MapStr
}

// WaitCloseMode enumerates the possible behaviors of WaitClose in a pipeline.
Expand Down Expand Up @@ -405,6 +407,10 @@ func makePipelineProcessors(
p.beatsMeta = common.MapStr{"beat": meta}
}

if meta := annotations.Host; meta != nil {
p.hostMeta = common.MapStr{"host": meta}
}

if em := annotations.Event; len(em.Fields) > 0 {
fields := common.MapStr{}
common.MergeFields(fields, em.Fields.Clone(), em.FieldsUnderRoot)
Expand Down
5 changes: 4 additions & 1 deletion libbeat/publisher/pipeline/processor.go
Original file line number Diff line number Diff line change
Expand Up @@ -99,10 +99,13 @@ func newProcessorPipeline(
// setup 5: client processor list
processors.add(localProcessors)

// setup 6: add beats metadata
// setup 6: add beats and metadata
if meta := global.beatsMeta; len(meta) > 0 {
processors.add(makeAddFieldsProcessor("beatsMeta", meta, needsCopy))
}
if meta := global.hostMeta; len(meta) > 0 {
processors.add(makeAddFieldsProcessor("hostMeta", meta, needsCopy))
}

// setup 7: pipeline processors list
processors.add(global.processors)
Expand Down

0 comments on commit 2cca46e

Please sign in to comment.