Hi, I created one watcher but the condition is not getting successful and returning hit =0, and finally, it is returning a null value. When I built the dashboard using the same condition value is getting displayed there, I also checked in the Preformatted text discover tab, Value is there.
This is the O/P
{
"_id" : "ab6c075c-1420-4826-b48b-c57b496e9eec_05ce93ef-c2cf-4245-8c9b-ca94cd5b5245-2021-07-14T14:03:30.068250852Z",
"watch_record" : {
"watch_id" : "ab6c075c-1420-4826-b48b-c57b496e9eec",
"node" : "n-2CcZomQIWiklu2KWP19g",
"state" : "execution_not_needed",
"status" : {
"state" : {
"active" : true,
"timestamp" : "2021-07-14T13:20:34.297Z"
},
"last_checked" : "2021-07-14T14:03:30.068Z",
"actions" : {
"netcool_webhook" : {
"ack" : {
"timestamp" : "2021-07-14T13:20:34.297Z",
"state" : "awaits_successful_execution"
}
},
"site_webhook" : {
"ack" : {
"timestamp" : "2021-07-14T13:20:34.297Z",
"state" : "awaits_successful_execution"
}
}
},
"execution_state" : "execution_not_needed",
"version" : 12
},
"trigger_event" : {
"type" : "manual",
"triggered_time" : "2021-07-14T14:03:30.068Z",
"manual" : {
"schedule" : {
"scheduled_time" : "2021-07-14T14:03:30.068Z"
}
}
},
"input" : {
"search" : {
"request" : {
"search_type" : "query_then_fetch",
"indices" : [
"4g-pm*"
],
"rest_total_hits_as_int" : true,
"body" : {
"query" : {
"bool" : {
"filter" : [
{
"bool" : {
"must" : [
{
"range" : {
"pm_data_source.timestamp" : {
"gte" : "now-30d"
}
}
},
{
"wildcard" : {
"pm_data_source.dn" : "LNCEL"
}
}
]
}
}
]
}
},
"aggregations" : {
"group_by_time" : {
"date_histogram" : {
"field" : "pm_data_source.timestamp",
"fixed_interval" : "1h"
},
"aggs" : {
"sum_M8009C7" : {
"sum" : {
"field" : "pm_data.LTE_Intra_eNB_HO_M8009C7"
}
},
"sum_M8009C2" : {
"sum" : {
"field" : "pm_data.LTE_Intra_eNB_HO_M8009C2"
}
},
"LTE_5043a" : {
"bucket_script" : {
"buckets_path" : {
"M8009C7" : "sum_M8009C7",
"M8009C2" : "sum_M8009C2"
},
"script" : "((100 * (params.M8009C7)) / (params.M8009C2))"
}
}
}
}
}
}
}
}
},
"condition" : {
"compare" : {
"ctx.payload.hits.total" : {
"gt" : 0
}
}
},
"metadata" : {
"name" : "LTE_5043a:E-UTRAN Total HO Success Ratio, intra eNB",
"xpack" : {
"type" : "json"
}
},
"result" : {
"execution_time" : "2021-07-14T14:03:30.068Z",
"execution_duration" : 42,
"input" : {
"type" : "search",
"status" : "success",
"payload" : {
"_shards" : {
"total" : 190,
"failed" : 0,
"successful" : 190,
"skipped" : 64
},
"hits" : {
"hits" : [ ],
"total" : 0,
"max_score" : null
},
"took" : 42,
"timed_out" : false,
"aggregations" : {
"group_by_time" : {
"buckets" : [ ]
}
}
},
"search" : {
"request" : {
"search_type" : "query_then_fetch",
"indices" : [
"4g-pm*"
],
"rest_total_hits_as_int" : true,
"body" : {
"query" : {
"bool" : {
"filter" : [
{
"bool" : {
"must" : [
{
"range" : {
"pm_data_source.timestamp" : {
"gte" : "now-30d"
}
}
},
{
"wildcard" : {
"pm_data_source.dn" : "LNCEL"
}
}
]
}
}
]
}
},
"aggregations" : {
"group_by_time" : {
"date_histogram" : {
"field" : "pm_data_source.timestamp",
"fixed_interval" : "1h"
},
"aggs" : {
"sum_M8009C7" : {
"sum" : {
"field" : "pm_data.LTE_Intra_eNB_HO_M8009C7"
}
},
"sum_M8009C2" : {
"sum" : {
"field" : "pm_data.LTE_Intra_eNB_HO_M8009C2"
}
},
"LTE_5043a" : {
"bucket_script" : {
"buckets_path" : {
"M8009C7" : "sum_M8009C7",
"M8009C2" : "sum_M8009C2"
},
"script" : "((100 * (params.M8009C7)) / (params.M8009C2))"
}
}
}
}
}
}
}
}
},
"condition" : {
"type" : "compare",
"status" : "success",
"met" : false,
"compare" : {
"resolved_values" : {
"ctx.payload.hits.total" : 0
}
}
},
"actions" : [ ]
},
"messages" : [ ]
}
}
This is the watcher config
{
"trigger": {
"schedule": {
"interval": "1d"
}
},
"input": {
"search": {
"request": {
"search_type": "query_then_fetch",
"indices": [
"4g-pm*"
],
"rest_total_hits_as_int": true,
"body": {
"query": {
"bool": {
"filter": [
{
"bool": {
"must": [
{
"range": {
"pm_data_source.timestamp": {
"gte": "now-30d"
}
}
},
{
"wildcard": {
"pm_data_source.dn": "LNCEL"
}
}
]
}
}
]
}
},
"aggregations": {
"group_by_time": {
"date_histogram": {
"field": "pm_data_source.timestamp",
"fixed_interval": "1h"
},
"aggs": {
"sum_M8009C7": {
"sum": {
"field": "pm_data.LTE_Intra_eNB_HO_M8009C7"
}
},
"sum_M8009C2": {
"sum": {
"field": "pm_data.LTE_Intra_eNB_HO_M8009C2"
}
},
"LTE_5043a": {
"bucket_script": {
"buckets_path": {
"M8009C7": "sum_M8009C7",
"M8009C2": "sum_M8009C2"
},
"script": "((100 * (params.M8009C7)) / (params.M8009C2))"
}
}
}
}
}
}
}
}
},
"condition": {
"compare": {
"ctx.payload.hits.total": {
"gt": 0
}
}
},
"actions": {
"site_webhook": {
"webhook": {
"scheme": "https",
"host": "webhook.site",
"port": 443,
"method": "post",
"path": "/8e84037f-08ce-48ec-853e-e995db7863d0",
"params": {
"watch_id": "{{ctx.watch_id}}"
},
"headers": {
"Content-type": "application/json"
},
"body": "{{#toJson}}ctx.payload{{/toJson}}"
}
},
"netcool_webhook": {
"webhook": {
"scheme": "http",
"host": "169.50.105.193",
"port": 10073,
"method": "post",
"path": "multicloudmanagedservices.ibm.com",
"params": {
"count": "{{ctx.payload.hits.total}}",
"watch_id": "{{ctx.watch_id}}"
},
"headers": {
"Content-type": "application/json"
},
"body": "{{#toJson}}ctx.payload{{/toJson}}"
}
}
},
"transform": {
"script": {
"source": """
String get_remarks(double x){
if(x >= 99){
return 'Good'
} else if(x == 98){
return 'Average'
} else {
return 'Poor'
}
}
BigDecimal round_to_decimal(double x){
return (BigDecimal.valueOf(x).setScale(2, RoundingMode.HALF_UP))
}
return [
'documents':ctx.payload.aggregations.group_by_time.buckets.stream()
.map(t -> { return [
'Client_name': 'Nokia',
'Metric Name': 'E-UTRAN Total HO Success Ratio, intra eNB',
'ALert Description': 'E-UTRAN Average',
'Timestamp': t.key_as_string,
'Remarks': get_remarks(t.LTE_5043a.value),
'Total HO Success Ratio, intra eNB - LTE_5043a(%)': t.LTE_5043a.value
] }).collect(Collectors.toList())
]
""",
"lang": "painless"
}
}
}