@@ -47,7 +47,7 @@ class DocumentMonitorRunnerIT : AlertingRestTestCase() {
47
47
48
48
val index = createTestIndex()
49
49
50
- val docQuery = DocLevelQuery (query = " test_field:\" us-west-2\" " , name = " 3" , fields = listOf () )
50
+ val docQuery = DocLevelQuery (query = " test_field:\" us-west-2\" " , name = " 3" )
51
51
val docLevelInput = DocLevelMonitorInput (" description" , listOf (index), listOf (docQuery))
52
52
53
53
val action = randomAction(template = randomTemplateScript(" Hello {{ctx.monitor.name}}" ), destinationId = createDestination().id)
@@ -108,7 +108,7 @@ class DocumentMonitorRunnerIT : AlertingRestTestCase() {
108
108
val index = createTestIndex()
109
109
110
110
val docQuery =
111
- DocLevelQuery (query = " test_field:\" us-west-2\" " , name = " 3" , fields = listOf (), queryFieldNames = listOf (" test_field" ))
111
+ DocLevelQuery (query = " test_field:\" us-west-2\" " , name = " 3" , queryFieldNames = listOf (" test_field" ))
112
112
val docLevelInput = DocLevelMonitorInput (" description" , listOf (index), listOf (docQuery))
113
113
114
114
val action = randomAction(template = randomTemplateScript(" Hello {{ctx.monitor.name}}" ), destinationId = createDestination().id)
@@ -154,7 +154,7 @@ class DocumentMonitorRunnerIT : AlertingRestTestCase() {
154
154
val index = createTestIndex()
155
155
156
156
val docQuery =
157
- DocLevelQuery (query = " test_field:\" us-west-2\" " , name = " 3" , fields = listOf () )
157
+ DocLevelQuery (query = " test_field:\" us-west-2\" " , name = " 3" )
158
158
val docLevelInput = DocLevelMonitorInput (" description" , listOf (index), listOf (docQuery))
159
159
160
160
val action = randomAction(template = randomTemplateScript(" Hello {{ctx.monitor.name}}" ), destinationId = createDestination().id)
@@ -199,7 +199,6 @@ class DocumentMonitorRunnerIT : AlertingRestTestCase() {
199
199
val docQuery = DocLevelQuery (
200
200
query = " test_field:\" us-west-2\" " ,
201
201
name = " 3" ,
202
- fields = listOf (),
203
202
queryFieldNames = listOf (" wrong_field" )
204
203
)
205
204
val docLevelInput = DocLevelMonitorInput (" description" , listOf (index), listOf (docQuery))
@@ -253,153 +252,6 @@ class DocumentMonitorRunnerIT : AlertingRestTestCase() {
253
252
val docQuery = DocLevelQuery (
254
253
query = " test_field:\" us-west-2\" " ,
255
254
name = " 3" ,
256
- fields = listOf (),
257
- queryFieldNames = listOf (" wrong_field" )
258
- )
259
- val docLevelInput = DocLevelMonitorInput (" description" , listOf (index), listOf (docQuery))
260
-
261
- val action = randomAction(template = randomTemplateScript(" Hello {{ctx.monitor.name}}" ), destinationId = createDestination().id)
262
- val monitor = randomDocumentLevelMonitor(
263
- inputs = listOf (docLevelInput),
264
- triggers = listOf (randomDocumentLevelTrigger(condition = ALWAYS_RUN , actions = listOf (action)))
265
- )
266
-
267
- indexDoc(index, " 1" , testDoc)
268
-
269
- val response = executeMonitor(monitor, params = DRYRUN_MONITOR )
270
-
271
- val output = entityAsMap(response)
272
- assertEquals(monitor.name, output[" monitor_name" ])
273
-
274
- assertEquals(1 , output.objectMap(" trigger_results" ).values.size)
275
-
276
- for (triggerResult in output.objectMap(" trigger_results" ).values) {
277
- assertEquals(1 , triggerResult.objectMap(" action_results" ).values.size)
278
- for (alertActionResult in triggerResult.objectMap(" action_results" ).values) {
279
- for (actionResult in alertActionResult.values) {
280
- @Suppress(" UNCHECKED_CAST" ) val actionOutput = (actionResult as Map <String , Map <String , String >>)[" output" ]
281
- as Map <String , String >
282
- assertEquals(" Hello ${monitor.name} " , actionOutput[" subject" ])
283
- assertEquals(" Hello ${monitor.name} " , actionOutput[" message" ])
284
- }
285
- }
286
- }
287
-
288
- val alerts = searchAlerts(monitor)
289
- assertEquals(" Alert saved for test monitor" , 0 , alerts.size)
290
- }
291
-
292
- fun `test dryrun execute monitor with queryFieldNames set up with correct field` () {
293
-
294
- val testTime = DateTimeFormatter .ISO_OFFSET_DATE_TIME .format(ZonedDateTime .now().truncatedTo(MILLIS ))
295
- val testDoc = """ {
296
- "message" : "This is an error from IAD region",
297
- "test_strict_date_time" : "$testTime ",
298
- "test_field" : "us-west-2"
299
- }"""
300
-
301
- val index = createTestIndex()
302
-
303
- val docQuery =
304
- DocLevelQuery (query = " test_field:\" us-west-2\" " , name = " 3" , fields = listOf (), queryFieldNames = listOf (" test_field" ))
305
- val docLevelInput = DocLevelMonitorInput (" description" , listOf (index), listOf (docQuery))
306
-
307
- val action = randomAction(template = randomTemplateScript(" Hello {{ctx.monitor.name}}" ), destinationId = createDestination().id)
308
- val monitor = randomDocumentLevelMonitor(
309
- inputs = listOf (docLevelInput),
310
- triggers = listOf (randomDocumentLevelTrigger(condition = ALWAYS_RUN , actions = listOf (action)))
311
- )
312
-
313
- indexDoc(index, " 1" , testDoc)
314
-
315
- val response = executeMonitor(monitor, params = DRYRUN_MONITOR )
316
-
317
- val output = entityAsMap(response)
318
- assertEquals(monitor.name, output[" monitor_name" ])
319
-
320
- assertEquals(1 , output.objectMap(" trigger_results" ).values.size)
321
-
322
- for (triggerResult in output.objectMap(" trigger_results" ).values) {
323
- assertEquals(1 , triggerResult.objectMap(" action_results" ).values.size)
324
- for (alertActionResult in triggerResult.objectMap(" action_results" ).values) {
325
- for (actionResult in alertActionResult.values) {
326
- @Suppress(" UNCHECKED_CAST" ) val actionOutput = (actionResult as Map <String , Map <String , String >>)[" output" ]
327
- as Map <String , String >
328
- assertEquals(" Hello ${monitor.name} " , actionOutput[" subject" ])
329
- assertEquals(" Hello ${monitor.name} " , actionOutput[" message" ])
330
- }
331
- }
332
- }
333
-
334
- val alerts = searchAlerts(monitor)
335
- assertEquals(" Alert saved for test monitor" , 0 , alerts.size)
336
- }
337
-
338
- fun `test dryrun execute monitor with queryFieldNames set up with wrong field` () {
339
-
340
- val testTime = DateTimeFormatter .ISO_OFFSET_DATE_TIME .format(ZonedDateTime .now().truncatedTo(MILLIS ))
341
- val testDoc = """ {
342
- "message" : "This is an error from IAD region",
343
- "test_strict_date_time" : "$testTime ",
344
- "test_field" : "us-west-2"
345
- }"""
346
-
347
- val index = createTestIndex()
348
- // using wrong field name
349
- val docQuery = DocLevelQuery (
350
- query = " test_field:\" us-west-2\" " ,
351
- name = " 3" ,
352
- fields = listOf (),
353
- queryFieldNames = listOf (" wrong_field" )
354
- )
355
- val docLevelInput = DocLevelMonitorInput (" description" , listOf (index), listOf (docQuery))
356
-
357
- val action = randomAction(template = randomTemplateScript(" Hello {{ctx.monitor.name}}" ), destinationId = createDestination().id)
358
- val monitor = randomDocumentLevelMonitor(
359
- inputs = listOf (docLevelInput),
360
- triggers = listOf (randomDocumentLevelTrigger(condition = ALWAYS_RUN , actions = listOf (action)))
361
- )
362
-
363
- indexDoc(index, " 1" , testDoc)
364
-
365
- val response = executeMonitor(monitor, params = DRYRUN_MONITOR )
366
-
367
- val output = entityAsMap(response)
368
- assertEquals(monitor.name, output[" monitor_name" ])
369
-
370
- assertEquals(1 , output.objectMap(" trigger_results" ).values.size)
371
-
372
- for (triggerResult in output.objectMap(" trigger_results" ).values) {
373
- assertEquals(0 , triggerResult.objectMap(" action_results" ).values.size)
374
- for (alertActionResult in triggerResult.objectMap(" action_results" ).values) {
375
- for (actionResult in alertActionResult.values) {
376
- @Suppress(" UNCHECKED_CAST" ) val actionOutput = (actionResult as Map <String , Map <String , String >>)[" output" ]
377
- as Map <String , String >
378
- assertEquals(" Hello ${monitor.name} " , actionOutput[" subject" ])
379
- assertEquals(" Hello ${monitor.name} " , actionOutput[" message" ])
380
- }
381
- }
382
- }
383
-
384
- val alerts = searchAlerts(monitor)
385
- assertEquals(" Alert saved for test monitor" , 0 , alerts.size)
386
- }
387
-
388
- fun `test fetch_query_field_names setting is disabled by configuring queryFieldNames set up with wrong field still works` () {
389
- adminClient().updateSettings(AlertingSettings .DOC_LEVEL_MONITOR_FETCH_ONLY_QUERY_FIELDS_ENABLED .key, " false" )
390
- val testTime = DateTimeFormatter .ISO_OFFSET_DATE_TIME .format(ZonedDateTime .now().truncatedTo(MILLIS ))
391
- val testDoc = """ {
392
- "message" : "This is an error from IAD region",
393
- "test_strict_date_time" : "$testTime ",
394
- "test_field" : "us-west-2"
395
- }"""
396
-
397
- val index = createTestIndex()
398
- // using wrong field name
399
- val docQuery = DocLevelQuery (
400
- query = " test_field:\" us-west-2\" " ,
401
- name = " 3" ,
402
- fields = listOf (),
403
255
queryFieldNames = listOf (" wrong_field" )
404
256
)
405
257
val docLevelInput = DocLevelMonitorInput (" description" , listOf (index), listOf (docQuery))
@@ -491,7 +343,7 @@ class DocumentMonitorRunnerIT : AlertingRestTestCase() {
491
343
"test_field" : "us-west-2"
492
344
}"""
493
345
494
- val docQuery = DocLevelQuery (query = " test_field:\" us-west-2\" " , name = " 3" , fields = listOf () )
346
+ val docQuery = DocLevelQuery (query = " test_field:\" us-west-2\" " , name = " 3" )
495
347
val docLevelInput = DocLevelMonitorInput (" description" , listOf (testIndex), listOf (docQuery))
496
348
497
349
val trigger = randomDocumentLevelTrigger(condition = ALWAYS_RUN )
@@ -537,7 +389,7 @@ class DocumentMonitorRunnerIT : AlertingRestTestCase() {
537
389
"test_field" : "us-east-1"
538
390
}"""
539
391
540
- val docQuery2 = DocLevelQuery (query = " test_field:\" us-east-1\" " , name = " 3" , fields = listOf () )
392
+ val docQuery2 = DocLevelQuery (query = " test_field:\" us-east-1\" " , name = " 3" )
541
393
val docLevelInput2 = DocLevelMonitorInput (" description" , listOf (testIndex2), listOf (docQuery2))
542
394
543
395
val trigger2 = randomDocumentLevelTrigger(condition = ALWAYS_RUN )
@@ -630,7 +482,7 @@ class DocumentMonitorRunnerIT : AlertingRestTestCase() {
630
482
"test_field" : "us-west-2"
631
483
}"""
632
484
633
- val docQuery = DocLevelQuery (query = " test_field:\" us-west-2\" " , name = " 3" , fields = listOf () )
485
+ val docQuery = DocLevelQuery (query = " test_field:\" us-west-2\" " , name = " 3" )
634
486
val docLevelInput = DocLevelMonitorInput (" description" , listOf (testIndex), listOf (docQuery))
635
487
636
488
val trigger = randomDocumentLevelTrigger(condition = ALWAYS_RUN )
@@ -668,7 +520,7 @@ class DocumentMonitorRunnerIT : AlertingRestTestCase() {
668
520
"test_field" : "us-west-2"
669
521
}"""
670
522
671
- val docQuery = DocLevelQuery (query = " test_field:\" us-west-2\" " , name = " 3" , fields = listOf () )
523
+ val docQuery = DocLevelQuery (query = " test_field:\" us-west-2\" " , name = " 3" )
672
524
val docLevelInput = DocLevelMonitorInput (" description" , listOf (testIndex), listOf (docQuery))
673
525
674
526
val trigger = randomDocumentLevelTrigger(condition = ALWAYS_RUN )
@@ -960,7 +812,7 @@ class DocumentMonitorRunnerIT : AlertingRestTestCase() {
960
812
"test_field" : "us-west-2"
961
813
}"""
962
814
963
- val docQuery = DocLevelQuery (query = " test_field:\" us-west-2\" " , name = testQueryName, fields = listOf () )
815
+ val docQuery = DocLevelQuery (query = " test_field:\" us-west-2\" " , name = testQueryName)
964
816
val docLevelInput = DocLevelMonitorInput (" description" , listOf (" $testIndexPrefix *" ), listOf (docQuery))
965
817
966
818
val trigger = randomDocumentLevelTrigger(condition = Script (" query[name=$testQueryName ]" ))
@@ -1839,7 +1691,7 @@ class DocumentMonitorRunnerIT : AlertingRestTestCase() {
1839
1691
false
1840
1692
)
1841
1693
1842
- val docQuery = DocLevelQuery (query = " test_field:\" us-west-2\" " , name = " 3" , fields = listOf () )
1694
+ val docQuery = DocLevelQuery (query = " test_field:\" us-west-2\" " , name = " 3" )
1843
1695
val docLevelInput = DocLevelMonitorInput (" description" , listOf (dataStreamName), listOf (docQuery))
1844
1696
1845
1697
val action = randomAction(template = randomTemplateScript(" Hello {{ctx.monitor.name}}" ), destinationId = createDestination().id)
@@ -1891,7 +1743,7 @@ class DocumentMonitorRunnerIT : AlertingRestTestCase() {
1891
1743
false
1892
1744
)
1893
1745
1894
- val docQuery = DocLevelQuery (query = " test_field:\" us-west-2\" " , name = " 3" , fields = listOf () )
1746
+ val docQuery = DocLevelQuery (query = " test_field:\" us-west-2\" " , name = " 3" )
1895
1747
val docLevelInput = DocLevelMonitorInput (" description" , listOf (dataStreamName), listOf (docQuery))
1896
1748
1897
1749
val action = randomAction(template = randomTemplateScript(" Hello {{ctx.monitor.name}}" ), destinationId = createDestination().id)
@@ -1953,7 +1805,7 @@ class DocumentMonitorRunnerIT : AlertingRestTestCase() {
1953
1805
""" .trimIndent()
1954
1806
)
1955
1807
1956
- val docQuery = DocLevelQuery (query = " test_field:\" us-west-2\" " , name = " 3" , fields = listOf () )
1808
+ val docQuery = DocLevelQuery (query = " test_field:\" us-west-2\" " , name = " 3" )
1957
1809
val docLevelInput = DocLevelMonitorInput (" description" , listOf (" $aliasName " ), listOf (docQuery))
1958
1810
1959
1811
val action = randomAction(template = randomTemplateScript(" Hello {{ctx.monitor.name}}" ), destinationId = createDestination().id)
@@ -2028,7 +1880,7 @@ class DocumentMonitorRunnerIT : AlertingRestTestCase() {
2028
1880
rolloverDatastream(dataStreamName2)
2029
1881
indexDoc(dataStreamName2, " 0" , testDoc)
2030
1882
2031
- val docQuery = DocLevelQuery (query = " test_field:\" us-west-2\" " , name = " 3" , fields = listOf () )
1883
+ val docQuery = DocLevelQuery (query = " test_field:\" us-west-2\" " , name = " 3" )
2032
1884
val docLevelInput = DocLevelMonitorInput (" description" , listOf (" test-datastream*" ), listOf (docQuery))
2033
1885
2034
1886
val action = randomAction(template = randomTemplateScript(" Hello {{ctx.monitor.name}}" ), destinationId = createDestination().id)
@@ -2102,7 +1954,7 @@ class DocumentMonitorRunnerIT : AlertingRestTestCase() {
2102
1954
rolloverDatastream(dataStreamName)
2103
1955
indexDoc(dataStreamName, " 0" , testDoc)
2104
1956
2105
- val docQuery = DocLevelQuery (query = " test_field:\" us-west-2\" " , name = " 3" , fields = listOf () )
1957
+ val docQuery = DocLevelQuery (query = " test_field:\" us-west-2\" " , name = " 3" )
2106
1958
val docLevelInput = DocLevelMonitorInput (" description" , listOf (dataStreamName), listOf (docQuery))
2107
1959
2108
1960
val action = randomAction(template = randomTemplateScript(" Hello {{ctx.monitor.name}}" ), destinationId = createDestination().id)
0 commit comments