Skip to content

Commit

Permalink
update object enabled:false index pattern attribs (#9644) (#9671)
Browse files Browse the repository at this point in the history
  • Loading branch information
simitt authored and graphaelli committed Dec 19, 2018
1 parent 12aa253 commit 2a470ee
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 0 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.asciidoc
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ https://github.com/elastic/beats/compare/v6.5.0...6.x[Check the HEAD diff]
- When collecting swap metrics for beats telemetry or system metricbeat module handle cases of free swap being bigger than total swap by assuming no swap is being used. {issue}6271[6271] {pull}9383[9383]
- Ignore non index fields in default_field for Elasticsearch. {pull}9549[9549]
- Update Golang to 1.10.6. {pull}9563[9563]
- Update Kibana index pattern attributes for objects that are disabled. {pull}9644[9644]
- Enforce validation for the Central Management access token. {issue}9621[9621]

*Auditbeat*
Expand Down
12 changes: 12 additions & 0 deletions libbeat/kibana/fields_transformer.go
Original file line number Diff line number Diff line change
Expand Up @@ -137,6 +137,18 @@ func transformField(version *common.Version, f common.Field) (common.MapStr, com
field["searchable"] = false
}

if f.Type == "object" && f.Enabled != nil {
enabled := getVal(f.Enabled, true)
field["enabled"] = enabled
if !enabled {
field["aggregatable"] = false
field["analyzed"] = false
field["doc_values"] = false
field["indexed"] = false
field["searchable"] = false
}
}

if f.Type == "text" {
field["aggregatable"] = false
}
Expand Down
7 changes: 7 additions & 0 deletions libbeat/kibana/fields_transformer_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -242,6 +242,13 @@ func TestTransformMisc(t *testing.T) {
{commonField: common.Field{Type: "binary"}, expected: false, attr: "doc_values"},
{commonField: common.Field{DocValues: &truthy, Type: "binary"}, expected: true, attr: "doc_values"},

// enabled - only applies to objects (and only if set)
{commonField: common.Field{Type: "binary", Enabled: &falsy}, expected: nil, attr: "enabled"},
{commonField: common.Field{Type: "binary", Enabled: &truthy}, expected: nil, attr: "enabled"},
{commonField: common.Field{Type: "object", Enabled: &truthy}, expected: true, attr: "enabled"},
{commonField: common.Field{Type: "object", Enabled: &falsy}, expected: false, attr: "enabled"},
{commonField: common.Field{Type: "object", Enabled: &falsy}, expected: false, attr: "doc_values"},

// indexed
{commonField: common.Field{Type: "binary"}, expected: false, attr: "indexed"},
{commonField: common.Field{Index: &truthy, Type: "binary"}, expected: false, attr: "indexed"},
Expand Down

0 comments on commit 2a470ee

Please sign in to comment.