Skip to content

Commit

Permalink
[Ingest Manager] Send datastreams fields (#20402) (#20442)
Browse files Browse the repository at this point in the history
[Ingest Manager] Send datastreams fields (#20402)
  • Loading branch information
michalpristas authored Aug 5, 2020
1 parent f91089f commit a3b2d53
Show file tree
Hide file tree
Showing 7 changed files with 26 additions and 24 deletions.
12 changes: 6 additions & 6 deletions x-pack/elastic-agent/pkg/agent/operation/monitoring.go
Original file line number Diff line number Diff line change
Expand Up @@ -190,10 +190,10 @@ func (o *Operator) getMonitoringFilebeatConfig(output interface{}) (map[string]i
"processors": []map[string]interface{}{
{
"add_fields": map[string]interface{}{
"target": "dataset",
"target": "data_stream",
"fields": map[string]interface{}{
"type": "logs",
"name": "elastic.agent",
"dataset": "elastic.agent",
"namespace": "default",
},
},
Expand Down Expand Up @@ -224,10 +224,10 @@ func (o *Operator) getMonitoringFilebeatConfig(output interface{}) (map[string]i
"processors": []map[string]interface{}{
{
"add_fields": map[string]interface{}{
"target": "dataset",
"target": "data_stream",
"fields": map[string]interface{}{
"type": "logs",
"name": fmt.Sprintf("elastic.agent.%s", name),
"dataset": fmt.Sprintf("elastic.agent.%s", name),
"namespace": "default",
},
},
Expand Down Expand Up @@ -274,10 +274,10 @@ func (o *Operator) getMonitoringMetricbeatConfig(output interface{}) (map[string
"processors": []map[string]interface{}{
{
"add_fields": map[string]interface{}{
"target": "dataset",
"target": "data_stream",
"fields": map[string]interface{}{
"type": "metrics",
"name": fmt.Sprintf("elastic.agent.%s", name),
"dataset": fmt.Sprintf("elastic.agent.%s", name),
"namespace": "default",
},
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,10 @@ filebeat:
index: logs-generic-default
processors:
- add_fields:
target: "dataset"
target: "data_stream"
fields:
type: logs
name: generic
dataset: generic
namespace: default
- add_fields:
target: "event"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,10 @@ filebeat:
index: logs-generic-default
processors:
- add_fields:
target: "dataset"
target: "data_stream"
fields:
type: logs
name: generic
dataset: generic
namespace: default
- add_fields:
target: "event"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,10 @@ filebeat:
index: logs-generic-default
processors:
- add_fields:
target: "dataset"
target: "data_stream"
fields:
type: logs
name: generic
dataset: generic
namespace: default
- add_fields:
target: "event"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,10 @@ filebeat:
var: value
processors:
- add_fields:
target: "dataset"
target: "data_stream"
fields:
type: logs
name: generic
dataset: generic
namespace: default
- add_fields:
target: "event"
Expand All @@ -27,10 +27,10 @@ filebeat:
var: value
processors:
- add_fields:
target: "dataset"
target: "data_stream"
fields:
type: testtype
name: generic
dataset: generic
namespace: default
- add_fields:
target: "event"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,10 @@ metricbeat:
hosts: ["http://127.0.0.1:8080"]
processors:
- add_fields:
target: "dataset"
target: "data_stream"
fields:
type: metrics
name: docker.status
dataset: docker.status
namespace: default
- add_fields:
target: "event"
Expand All @@ -21,10 +21,10 @@ metricbeat:
hosts: ["http://127.0.0.1:8080"]
processors:
- add_fields:
target: "dataset"
target: "data_stream"
fields:
type: metrics
name: generic
dataset: generic
namespace: default
- add_fields:
target: "event"
Expand All @@ -39,10 +39,10 @@ metricbeat:
fields:
should_be: first
- add_fields:
target: "dataset"
target: "data_stream"
fields:
type: metrics
name: generic
dataset: generic
namespace: testing
- add_fields:
target: "event"
Expand Down
6 changes: 4 additions & 2 deletions x-pack/elastic-agent/pkg/agent/transpiler/rules.go
Original file line number Diff line number Diff line change
Expand Up @@ -632,16 +632,18 @@ func (r *InjectStreamProcessorRule) Apply(ast *AST) error {
return errors.New("InjectStreamProcessorRule: processors is not a list")
}

// datastream
processorMap := &Dict{value: make([]Node, 0)}
processorMap.value = append(processorMap.value, &Key{name: "target", value: &StrVal{value: "dataset"}})
processorMap.value = append(processorMap.value, &Key{name: "target", value: &StrVal{value: "data_stream"}})
processorMap.value = append(processorMap.value, &Key{name: "fields", value: &Dict{value: []Node{
&Key{name: "type", value: &StrVal{value: datasetType}},
&Key{name: "namespace", value: &StrVal{value: namespace}},
&Key{name: "name", value: &StrVal{value: dataset}},
&Key{name: "dataset", value: &StrVal{value: dataset}},
}}})
addFieldsMap := &Dict{value: []Node{&Key{"add_fields", processorMap}}}
processorsList.value = mergeStrategy(r.OnConflict).InjectItem(processorsList.value, addFieldsMap)

// event
processorMap = &Dict{value: make([]Node, 0)}
processorMap.value = append(processorMap.value, &Key{name: "target", value: &StrVal{value: "event"}})
processorMap.value = append(processorMap.value, &Key{name: "fields", value: &Dict{value: []Node{
Expand Down

0 comments on commit a3b2d53

Please sign in to comment.