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

Cherry-pick #18967 to 7.x: Moved from stream to dataset #19093

Merged
merged 1 commit into from
Jun 12, 2020
Merged
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 x-pack/elastic-agent/CHANGELOG.asciidoc
Original file line number Diff line number Diff line change
Expand Up @@ -70,3 +70,4 @@
- When not port are specified and the https is used fallback to 443 {pull}18844[18844]
- Change monitoring defaults for agent {pull}18927[18927]
- Agent verifies packages before using them {pull}18876[18876]
- Change stream.* to dataset.* fields {pull}18967[18967]
24 changes: 22 additions & 2 deletions x-pack/elastic-agent/pkg/agent/operation/monitoring.go
Original file line number Diff line number Diff line change
Expand Up @@ -180,7 +180,17 @@ func (o *Operator) getMonitoringFilebeatConfig(output interface{}) (map[string]i
"paths": paths,
"index": "logs-agent-default",
"processors": []map[string]interface{}{
map[string]interface{}{
{
"add_fields": map[string]interface{}{
"target": "dataset",
"fields": map[string]interface{}{
"type": "logs",
"name": "agent",
"namespace": "default",
},
},
},
{
"add_fields": map[string]interface{}{
"target": "stream",
"fields": map[string]interface{}{
Expand Down Expand Up @@ -220,7 +230,17 @@ func (o *Operator) getMonitoringMetricbeatConfig(output interface{}) (map[string
"hosts": hosts,
"index": "metrics-agent-default",
"processors": []map[string]interface{}{
map[string]interface{}{
{
"add_fields": map[string]interface{}{
"target": "dataset",
"fields": map[string]interface{}{
"type": "metrics",
"name": "agent",
"namespace": "default",
},
},
},
{
"add_fields": map[string]interface{}{
"target": "stream",
"fields": map[string]interface{}{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,12 @@ filebeat:
dataset: generic
index: logs-generic-default
processors:
- add_fields:
target: "dataset"
fields:
type: logs
name: generic
namespace: default
- add_fields:
target: "stream"
fields:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,12 @@ filebeat:
dataset: generic
index: logs-generic-default
processors:
- add_fields:
target: "dataset"
fields:
type: logs
name: generic
namespace: default
- add_fields:
target: "stream"
fields:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,12 @@ filebeat:
dataset: generic
index: logs-generic-default
processors:
- add_fields:
target: "dataset"
fields:
type: logs
name: generic
namespace: default
- add_fields:
target: "stream"
fields:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,12 @@ filebeat:
vars:
var: value
processors:
- add_fields:
target: "dataset"
fields:
type: logs
name: generic
namespace: default
- add_fields:
target: "stream"
fields:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,12 @@ metricbeat:
index: metrics-docker.status-default
hosts: ["http://127.0.0.1:8080"]
processors:
- add_fields:
target: "dataset"
fields:
type: metrics
name: docker.status
namespace: default
- add_fields:
target: "stream"
fields:
Expand All @@ -16,6 +22,12 @@ metricbeat:
index: metrics-generic-default
hosts: ["http://127.0.0.1:8080"]
processors:
- add_fields:
target: "dataset"
fields:
type: metrics
name: generic
namespace: default
- add_fields:
target: "stream"
fields:
Expand All @@ -30,12 +42,19 @@ metricbeat:
- add_fields:
fields:
should_be: first
- add_fields:
target: "dataset"
fields:
type: metrics
name: generic
namespace: testing
- add_fields:
target: "stream"
fields:
type: metrics
dataset: generic
namespace: testing

output:
elasticsearch:
hosts: [127.0.0.1:9200, 127.0.0.1:9300]
Expand Down
18 changes: 16 additions & 2 deletions x-pack/elastic-agent/pkg/agent/transpiler/rules.go
Original file line number Diff line number Diff line change
Expand Up @@ -628,15 +628,29 @@ 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: "target", value: &StrVal{value: "dataset"}})
processorMap.value = append(processorMap.value, &Key{name: "fields", value: &Dict{value: []Node{
&Key{name: "type", value: &StrVal{value: r.Type}},
&Key{name: "namespace", value: &StrVal{value: namespace}},
&Key{name: "dataset", value: &StrVal{value: dataset}},
&Key{name: "name", value: &StrVal{value: dataset}},
}}})

addFieldsMap := &Dict{value: []Node{&Key{"add_fields", processorMap}}}
processorsList.value = mergeStrategy(r.OnConflict).InjectItem(processorsList.value, addFieldsMap)

// add this for backwards compatibility remove later
streamProcessorMap := &Dict{value: make([]Node, 0)}
streamProcessorMap.value = append(streamProcessorMap.value, &Key{name: "target", value: &StrVal{value: "stream"}})
streamProcessorMap.value = append(streamProcessorMap.value, &Key{name: "fields", value: &Dict{value: []Node{
&Key{name: "type", value: &StrVal{value: r.Type}},
&Key{name: "namespace", value: &StrVal{value: namespace}},
&Key{name: "dataset", value: &StrVal{value: dataset}},
}}})

streamAddFieldsMap := &Dict{value: []Node{&Key{"add_fields", streamProcessorMap}}}

processorsList.value = mergeStrategy(r.OnConflict).InjectItem(processorsList.value, streamAddFieldsMap)
// end of backward compatibility section
}
}
}
Expand Down