Skip to content

Commit 07332ef

Browse files
authored
[Logs+] Change default of ignore_malformed to true in logs-*-* data streams (#95329)
1 parent af8725f commit 07332ef

File tree

5 files changed

+123
-1
lines changed

5 files changed

+123
-1
lines changed

docs/changelog/95329.yaml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
pr: 95329
2+
summary: Change default of `ignore_malformed` to `true` in `logs-*-*` data streams
3+
area: Data streams
4+
type: enhancement
5+
issues:
6+
- 95224
Lines changed: 108 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,108 @@
1+
---
2+
Verify default logs-*-* settings and mappings:
3+
- do:
4+
indices.create_data_stream:
5+
name: logs-generic-default
6+
- is_true: acknowledged
7+
8+
- do:
9+
indices.get_data_stream:
10+
name: logs-generic-default
11+
- set: { data_streams.0.indices.0.index_name: idx0name }
12+
13+
# default backing index settings should be "ignore_malformed": true
14+
- do:
15+
indices.get_settings:
16+
index: $idx0name
17+
- match: { .$idx0name.settings.index.mapping.ignore_malformed: "true" }
18+
19+
# add test field mapping
20+
- do:
21+
indices.put_mapping:
22+
index: $idx0name
23+
body:
24+
properties:
25+
numeric_field:
26+
type: integer
27+
- is_true: acknowledged
28+
29+
# default backing index mapping should contain an exception for the @timestamp field - "ignore_malformed": false
30+
- do:
31+
indices.get_mapping:
32+
index: $idx0name
33+
- match: { .$idx0name.mappings.properties.@timestamp.ignore_malformed: false }
34+
- match: { .$idx0name.mappings.properties.numeric_field.type: "integer" }
35+
36+
- do:
37+
index:
38+
index: logs-generic-default
39+
refresh: true
40+
body:
41+
'@timestamp': '2023-04-18'
42+
message: 'valid'
43+
numeric_field: 42
44+
- match: {result: "created"}
45+
46+
- do:
47+
search:
48+
index: logs-generic-default
49+
body:
50+
query:
51+
term:
52+
message:
53+
value: 'valid'
54+
fields:
55+
- field: 'numeric_field'
56+
- length: { hits.hits: 1 }
57+
- length: { hits.hits.0.fields: 1 }
58+
- match: { hits.hits.0.fields.numeric_field.0: 42 }
59+
60+
- do:
61+
index:
62+
index: logs-generic-default
63+
refresh: true
64+
body:
65+
'@timestamp': '2023-04-18'
66+
message: 'number_as_string'
67+
numeric_field: "42"
68+
- match: {result: "created"}
69+
70+
- do:
71+
search:
72+
index: logs-generic-default
73+
body:
74+
query:
75+
term:
76+
message:
77+
value: 'number_as_string'
78+
fields:
79+
- field: 'numeric_field'
80+
- length: { hits.hits: 1 }
81+
- length: { hits.hits.0.fields: 1 }
82+
- match: { hits.hits.0.fields.numeric_field.0: 42 }
83+
84+
- do:
85+
index:
86+
index: logs-generic-default
87+
refresh: true
88+
body:
89+
'@timestamp': '2023-04-18'
90+
message: 'invalid'
91+
numeric_field: "forty-two"
92+
- match: {result: "created"}
93+
94+
- do:
95+
search:
96+
index: logs-generic-default
97+
body:
98+
query:
99+
term:
100+
message:
101+
value: 'invalid'
102+
fields:
103+
- field: 'numeric_field'
104+
- length: { hits.hits: 1 }
105+
- length: { hits.hits.0._ignored: 1 }
106+
- match: { hits.hits.0._ignored.0: 'numeric_field' }
107+
- length: { hits.hits.0.ignored_field_values.numeric_field: 1 }
108+
- match: { hits.hits.0.ignored_field_values.numeric_field.0: 'forty-two' }

x-pack/plugin/core/src/main/resources/data-streams-mappings.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,8 @@
3333
"date_detection": false,
3434
"properties": {
3535
"@timestamp": {
36-
"type": "date"
36+
"type": "date",
37+
"ignore_malformed": false
3738
},
3839
"data_stream": {
3940
"properties": {

x-pack/plugin/core/src/main/resources/logs-mappings.json

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,10 @@
22
"template": {
33
"mappings": {
44
"properties": {
5+
"@timestamp": {
6+
"type": "date",
7+
"ignore_malformed": false
8+
},
59
"data_stream": {
610
"properties": {
711
"type": {

x-pack/plugin/core/src/main/resources/logs-settings.json

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,9 @@
88
"codec": "best_compression",
99
"query": {
1010
"default_field": ["message"]
11+
},
12+
"mapping": {
13+
"ignore_malformed": true
1114
}
1215
}
1316
}

0 commit comments

Comments
 (0)