Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Ingest Manager] Send datastreams fields #20402

Merged
merged 6 commits into from
Aug 5, 2020
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
20 changes: 20 additions & 0 deletions x-pack/elastic-agent/pkg/agent/operation/monitoring.go
Original file line number Diff line number Diff line change
Expand Up @@ -198,6 +198,16 @@ func (o *Operator) getMonitoringFilebeatConfig(output interface{}) (map[string]i
},
},
},
{
"add_fields": map[string]interface{}{
"target": "datastream",
"fields": map[string]interface{}{
"type": "logs",
"dataset": "elastic.agent",
"namespace": "default",
},
},
},
{
"add_fields": map[string]interface{}{
"target": "event",
Expand Down Expand Up @@ -232,6 +242,16 @@ func (o *Operator) getMonitoringFilebeatConfig(output interface{}) (map[string]i
},
},
},
{
"add_fields": map[string]interface{}{
"target": "datastream",
"fields": map[string]interface{}{
"type": "logs",
"dataset": "elastic.agent",
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is wrong, should be fmt.Sprintf("elastic.agent.%s", name)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@blakerouse updated

"namespace": "default",
},
},
},
{
"add_fields": map[string]interface{}{
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You missed adding it to getMonitoringMetricbeatConfig

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

thanks, i totally missed that

"target": "event",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,12 @@ filebeat:
type: logs
name: generic
namespace: default
- add_fields:
target: "datastream"
fields:
type: logs
dataset: generic
namespace: default
- add_fields:
target: "event"
fields:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,12 @@ filebeat:
type: logs
name: generic
namespace: default
- add_fields:
target: "datastream"
fields:
type: logs
dataset: generic
namespace: default
- add_fields:
target: "event"
fields:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,12 @@ filebeat:
type: logs
name: generic
namespace: default
- add_fields:
target: "datastream"
fields:
type: logs
dataset: generic
namespace: default
- add_fields:
target: "event"
fields:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,12 @@ filebeat:
type: logs
name: generic
namespace: default
- add_fields:
target: "datastream"
fields:
type: logs
dataset: generic
namespace: default
- add_fields:
target: "event"
fields:
Expand All @@ -32,6 +38,12 @@ filebeat:
type: testtype
name: generic
namespace: default
- add_fields:
target: "datastream"
fields:
type: testtype
dataset: generic
namespace: default
- add_fields:
target: "event"
fields:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,12 @@ metricbeat:
type: metrics
name: docker.status
namespace: default
- add_fields:
target: "datastream"
fields:
type: metrics
dataset: docker.status
namespace: default
- add_fields:
target: "event"
fields:
Expand All @@ -26,6 +32,12 @@ metricbeat:
type: metrics
name: generic
namespace: default
- add_fields:
target: "datastream"
fields:
type: metrics
dataset: generic
namespace: default
- add_fields:
target: "event"
fields:
Expand All @@ -44,6 +56,12 @@ metricbeat:
type: metrics
name: generic
namespace: testing
- add_fields:
target: "datastream"
fields:
type: metrics
dataset: generic
namespace: testing
- add_fields:
target: "event"
fields:
Expand Down
13 changes: 13 additions & 0 deletions x-pack/elastic-agent/pkg/agent/transpiler/rules.go
Original file line number Diff line number Diff line change
Expand Up @@ -632,6 +632,7 @@ func (r *InjectStreamProcessorRule) Apply(ast *AST) error {
return errors.New("InjectStreamProcessorRule: processors is not a list")
}

// dataset
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: "fields", value: &Dict{value: []Node{
Expand All @@ -642,6 +643,18 @@ func (r *InjectStreamProcessorRule) Apply(ast *AST) error {
addFieldsMap := &Dict{value: []Node{&Key{"add_fields", processorMap}}}
processorsList.value = mergeStrategy(r.OnConflict).InjectItem(processorsList.value, addFieldsMap)

// datastream
processorMap = &Dict{value: make([]Node, 0)}
processorMap.value = append(processorMap.value, &Key{name: "target", value: &StrVal{value: "datastream"}})
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: "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