@@ -12,6 +12,18 @@ If your {dfeed} defines runtime fields, you can use those fields in your
12
12
functions in one or more detectors. Runtime fields can impact search performance
13
13
based on the computation defined in the runtime script.
14
14
15
+ [NOTE]
16
+ ===============================
17
+ Some of these examples use regular expressions. By default, regular
18
+ expressions are disabled because they circumvent the protection that Painless
19
+ provides against long running and memory hungry scripts. For more information,
20
+ see {ref}/modules-scripting-painless.html[Painless scripting language].
21
+
22
+ {ml-cap} analysis is case sensitive. For example, "John" is considered to be
23
+ different than "john". This is one reason you might consider using scripts that
24
+ convert your strings to upper or lowercase letters.
25
+ ===============================
26
+
15
27
* <<ml-configuring-transform1>>
16
28
* <<ml-configuring-transform2>>
17
29
* <<ml-configuring-transform3>>
@@ -31,46 +43,22 @@ PUT /my-index-000001
31
43
{
32
44
"mappings":{
33
45
"properties": {
34
- "@timestamp": {
35
- "type": "date"
36
- },
37
- "aborted_count": {
38
- "type": "long"
39
- },
40
- "another_field": {
41
- "type": "keyword" <1>
42
- },
43
- "clientip": {
44
- "type": "keyword"
45
- },
46
+ "@timestamp": { "type": "date" },
47
+ "aborted_count": { "type": "long" },
48
+ "another_field": { "type": "keyword" }, <1>
49
+ "clientip": { "type": "keyword" },
46
50
"coords": {
47
51
"properties": {
48
- "lat": {
49
- "type": "keyword"
50
- },
51
- "lon": {
52
- "type": "keyword"
53
- }
52
+ "lat": { "type": "keyword" },
53
+ "lon": { "type": "keyword" }
54
54
}
55
55
},
56
- "error_count": {
57
- "type": "long"
58
- },
59
- "query": {
60
- "type": "keyword"
61
- },
62
- "some_field": {
63
- "type": "keyword"
64
- },
65
- "tokenstring1":{
66
- "type":"keyword"
67
- },
68
- "tokenstring2":{
69
- "type":"keyword"
70
- },
71
- "tokenstring3":{
72
- "type":"keyword"
73
- }
56
+ "error_count": { "type": "long" },
57
+ "query": { "type": "keyword" },
58
+ "some_field": { "type": "keyword" },
59
+ "tokenstring1":{ "type":"keyword" },
60
+ "tokenstring2":{ "type":"keyword" },
61
+ "tokenstring3":{ "type":"keyword" }
74
62
}
75
63
}
76
64
}
@@ -113,14 +101,12 @@ PUT _ml/anomaly_detectors/test1
113
101
"detectors":[
114
102
{
115
103
"function":"mean",
116
- "field_name": "total_error_count", <1>
117
- "detector_description": "Custom script field transformation"
104
+ "field_name": "total_error_count" <1>
118
105
}
119
106
]
120
107
},
121
108
"data_description": {
122
- "time_field":"@timestamp",
123
- "time_format":"epoch_ms"
109
+ "time_field":"@timestamp"
124
110
}
125
111
}
126
112
@@ -130,11 +116,6 @@ PUT _ml/datafeeds/datafeed-test1
130
116
"indices": [
131
117
"my-index-000001"
132
118
],
133
- "query": {
134
- "match_all": {
135
- "boost": 1
136
- }
137
- },
138
119
"runtime_mappings": {
139
120
"total_error_count": { <2>
140
121
"type": "long",
@@ -194,24 +175,6 @@ use the **Edit JSON** tab. For example:
194
175
image::images/ml-runtimefields.jpg[Using runtime_mappings in {dfeed} config via {kib}]
195
176
196
177
197
- [[ml-configuring-transform-examples]]
198
- == Common runtime field examples
199
-
200
- While the possibilities are limitless, there are a number of common scenarios
201
- where you might use runtime fields in your {dfeeds}.
202
-
203
- [NOTE]
204
- ===============================
205
- Some of these examples use regular expressions. By default, regular
206
- expressions are disabled because they circumvent the protection that Painless
207
- provides against long running and memory hungry scripts. For more information,
208
- see {ref}/modules-scripting-painless.html[Painless scripting language].
209
-
210
- {ml-cap} analysis is case sensitive. For example, "John" is considered to be
211
- different than "john". This is one reason you might consider using scripts that
212
- convert your strings to upper or lowercase letters.
213
- ===============================
214
-
215
178
[[ml-configuring-transform2]]
216
179
.Example 2: Concatenating strings
217
180
@@ -224,26 +187,19 @@ PUT _ml/anomaly_detectors/test2
224
187
"detectors":[
225
188
{
226
189
"function":"low_info_content",
227
- "field_name":"my_runtime_field", <1>
228
- "detector_description": "Custom script field transformation"
190
+ "field_name":"my_runtime_field" <1>
229
191
}
230
192
]
231
193
},
232
194
"data_description": {
233
- "time_field":"@timestamp",
234
- "time_format":"epoch_ms"
195
+ "time_field":"@timestamp"
235
196
}
236
197
}
237
198
238
199
PUT _ml/datafeeds/datafeed-test2
239
200
{
240
201
"job_id": "test2",
241
202
"indices": ["my-index-000001"],
242
- "query": {
243
- "match_all": {
244
- "boost": 1
245
- }
246
- },
247
203
"runtime_mappings": {
248
204
"my_runtime_field": {
249
205
"type": "keyword",
@@ -469,7 +425,7 @@ The preview {dfeed} API returns the following results, which show that
469
425
470
426
[source,console]
471
427
--------------------------------------------------
472
- PUT _ml/anomaly_detectors/test4
428
+ PUT _ml/anomaly_detectors/test3
473
429
{
474
430
"analysis_config":{
475
431
"bucket_span": "10m",
@@ -481,20 +437,14 @@ PUT _ml/anomaly_detectors/test4
481
437
]
482
438
},
483
439
"data_description": {
484
- "time_field":"@timestamp",
485
- "time_format":"epoch_ms"
440
+ "time_field":"@timestamp"
486
441
}
487
442
}
488
443
489
- PUT _ml/datafeeds/datafeed-test4
444
+ PUT _ml/datafeeds/datafeed-test3
490
445
{
491
- "job_id": "test4 ",
446
+ "job_id": "test3 ",
492
447
"indices": ["my-index-000001"],
493
- "query": {
494
- "match_all": {
495
- "boost": 1
496
- }
497
- },
498
448
"runtime_mappings": {
499
449
"my_coordinates": {
500
450
"type": "keyword",
@@ -505,7 +455,7 @@ PUT _ml/datafeeds/datafeed-test4
505
455
}
506
456
}
507
457
508
- GET _ml/datafeeds/datafeed-test4 /_preview
458
+ GET _ml/datafeeds/datafeed-test3 /_preview
509
459
--------------------------------------------------
510
460
// TEST[skip:needs-licence]
511
461
@@ -534,7 +484,7 @@ The preview {dfeed} API returns the following results, which show that
534
484
535
485
[source,console]
536
486
--------------------------------------------------
537
- PUT _ml/anomaly_detectors/test3
487
+ PUT _ml/anomaly_detectors/test4
538
488
{
539
489
"description":"DNS tunneling",
540
490
"analysis_config":{
@@ -550,20 +500,14 @@ PUT _ml/anomaly_detectors/test3
550
500
]
551
501
},
552
502
"data_description": {
553
- "time_field":"@timestamp",
554
- "time_format":"epoch_ms"
503
+ "time_field":"@timestamp"
555
504
}
556
505
}
557
506
558
- PUT _ml/datafeeds/datafeed-test3
507
+ PUT _ml/datafeeds/datafeed-test4
559
508
{
560
- "job_id": "test3 ",
509
+ "job_id": "test4 ",
561
510
"indices": ["my-index-000001"],
562
- "query": {
563
- "match_all": {
564
- "boost": 1
565
- }
566
- },
567
511
"script_fields":{
568
512
"sub":{
569
513
"script":"return domainSplit(doc['query'].value).get(0);"
@@ -574,7 +518,7 @@ PUT _ml/datafeeds/datafeed-test3
574
518
}
575
519
}
576
520
577
- GET _ml/datafeeds/datafeed-test3 /_preview
521
+ GET _ml/datafeeds/datafeed-test4 /_preview
578
522
--------------------------------------------------
579
523
// TEST[skip:needs-licence]
580
524
0 commit comments