Hi all,
I created advanced alert on watcher. But my condition didnt work. I want to calculate first input divide to second input. but cannot calculate.
Can you help me?
My condition ->
"condition": {
"script": {
"source": "return (ctx.payload.first.hits.total / ctx.payload.second.hits.total) > 0.8",
"lang": "painless"**
}
My json->
{
"trigger": {
"schedule": {
"interval": "1h"
}
},
"input": {
"chain": {
"inputs": [
{
"first": {
"search": {
"request": {
"search_type": "query_then_fetch",
"indices": [
"graylog*"
],
"types": ,
"body": {
"query": {
"bool": {
"must": [
{
"match": {
"ctxt_page_name": "Thank You"
}
}
],
"filter": {
"range": {
"timestamp": {
"gte": "now-10m"
}
}
}
}
}
}
},
"extract": [
"hits.total"
]
}
}
},
{
"second": {
"search": {
"request": {
"search_type": "query_then_fetch",
"indices": ,
"types": ,
"body": {
"query": {
"bool": {
"must": [
{
"match": {
"ctxt_page_name": "Payment"
}
}
],
"filter": {
"range": {
"timestamp": {
"gte": "now-10m"
}
}
}
}
}
}
},
"extract": [
"hits.total"
]
}
}
}
]
}
},
"condition": {
"script": {
"source": "return (ctx.payload.first.hits.total / ctx.payload.second.hits.total) > 0.8",
"lang": "painless"
}
},
"actions": {
"send_email": {
"email": {
"profile": "standard",
"to": [
"cem.kuleyin@enuygun.com"
],
"subject": "Watcher Notification",
"body": {
"text": "{{ctx.payload.first.hits.total}} Thank You - {{ctx.payload.second.hits.total}} Payment "
}
}
}
},
"throttle_period_in_millis": 60000
}