Skip to content

Commit

Permalink
[Elastic-Agent] Moved stream.* fields to top of event (elastic#17858)
Browse files Browse the repository at this point in the history
[Elastic-Agent] Moved stream.* fields to top of event (elastic#17858)
  • Loading branch information
michalpristas committed Apr 22, 2020
1 parent 448f345 commit 2b8d04a
Show file tree
Hide file tree
Showing 7 changed files with 29 additions and 21 deletions.
1 change: 1 addition & 0 deletions x-pack/elastic-agent/CHANGELOG.asciidoc
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
- Rename the User-Agent string from Beats Agent to Elastic Agent. {pull}17765[17765]
- Remove the kbn-version on each request to the Kibana API. {pull}17764[17764]
- Make sure that the Elastic Agent connect over TLS in cloud. {pull}17843[17843]
- Moved stream.* fields to top of event {pull}17858[17858]

==== New features

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,11 @@ filebeat:
index: logs-generic-default
processors:
- add_fields:
target: "stream"
fields:
stream.type: logs
stream.dataset: generic
stream.namespace: default
type: logs
dataset: generic
namespace: default
output:
elasticsearch:
hosts:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,11 @@ filebeat:
index: logs-generic-default
processors:
- add_fields:
target: "stream"
fields:
stream.type: logs
stream.dataset: generic
stream.namespace: default
type: logs
dataset: generic
namespace: default
output:
elasticsearch:
enabled: true
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,11 @@ filebeat:
index: logs-generic-default
processors:
- add_fields:
target: "stream"
fields:
stream.type: logs
stream.dataset: generic
stream.namespace: default
type: logs
dataset: generic
namespace: default
output:
elasticsearch:
hosts:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,11 @@ filebeat:
var: value
processors:
- add_fields:
target: "stream"
fields:
stream.type: logs
stream.dataset: generic
stream.namespace: default
type: logs
dataset: generic
namespace: default
output:
elasticsearch:
hosts:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,11 @@ metricbeat:
hosts: ["http://127.0.0.1:8080"]
processors:
- add_fields:
target: "stream"
fields:
stream.type: metrics
stream.dataset: docker.status
stream.namespace: default
type: metrics
dataset: docker.status
namespace: default
- module: apache
metricsets: [info]
index: metrics-generic-testing
Expand All @@ -19,10 +20,11 @@ metricbeat:
fields:
should_be: first
- add_fields:
target: "stream"
fields:
stream.type: metrics
stream.dataset: generic
stream.namespace: testing
type: metrics
dataset: generic
namespace: testing
output:
elasticsearch:
hosts: [127.0.0.1:9200, 127.0.0.1:9300]
Expand Down
7 changes: 4 additions & 3 deletions x-pack/elastic-agent/pkg/agent/transpiler/rules.go
Original file line number Diff line number Diff line change
Expand Up @@ -523,10 +523,11 @@ func (r *InjectStreamProcessorRule) Apply(ast *AST) error {
}

processorMap := &Dict{value: make([]Node, 0)}
processorMap.value = append(processorMap.value, &Key{name: "target", value: &StrVal{value: "stream"}})
processorMap.value = append(processorMap.value, &Key{name: "fields", value: &Dict{value: []Node{
&Key{name: "stream.type", value: &StrVal{value: r.Type}},
&Key{name: "stream.namespace", value: &StrVal{value: namespace}},
&Key{name: "stream.dataset", value: &StrVal{value: dataset}},
&Key{name: "type", value: &StrVal{value: r.Type}},
&Key{name: "namespace", value: &StrVal{value: namespace}},
&Key{name: "dataset", value: &StrVal{value: dataset}},
}}})

addFieldsMap := &Dict{value: []Node{&Key{"add_fields", processorMap}}}
Expand Down

0 comments on commit 2b8d04a

Please sign in to comment.