Hi all,
I am using 2 inputs in watcher. In the first input I have aggreagation level detail of error_codes, I want to use those error_codes as filter in my second input. I have tried below but this is not working. Kindly assist in this.
Below is my watcher script-
{
"trigger": {
"schedule": {
"hourly": {
"minute": [
0,
30
]
}
}
},
"input": {
"chain": {
"inputs": [
{
"me": {
"search": {
"request": {
"search_type": "query_then_fetch",
"indices": [
"me"
],
"rest_total_hits_as_int": true,
"body": {
"size": 0,
"query": {
"bool": {
"must": [
{
"match_all": {}
}
],
"filter": [
{
"range": {
"time": {
"gte": "{{ctx.trigger.scheduled_time}}||-7d",
"lte": "{{ctx.trigger.scheduled_time}}",
"format": "strict_date_optional_time||epoch_millis"
}
}
}
],
"should": [],
"must_not": []
}
},
"aggs": {
"error_codes": {
"terms": {
"field": "_id",
"order": {
"_count": "desc"
},
"size": 5
}
}
}
}
}
}
}
},
{
"error_list": {
"transform": {
"script": {
"source": """
def keys = [];
for (bucket in ctx.payload.me.aggregations.error_codes.buckets) {
keys.add(bucket.key);
}
return keys;
"""
}
}
}
}
{
"low": {
"search": {
"request": {
"search_type": "query_then_fetch",
"indices": [
"mer"
],
"rest_total_hits_as_int": true,
"body": {
"size": 0,
"query": {
"bool": {
"must": [
{
"match_all": {}
}
],
"filter": [
{
"range": {
"time": {
"gte": "{{ctx.trigger.scheduled_time}}||-24h",
"lte": "{{ctx.trigger.scheduled_time}}",
"format": "strict_date_optional_time||epoch_millis"
}
}
},
{
"terms": {
"error_codes": [
"{{ctx.payload.error_list._value}}"
]
}
}
],
"should": [],
"must_not": []
}
},
"aggs": {
"error_codes": {
"terms": {
"field": "error_codes",
"order": {
"_count": "desc"
},
"size": 5
}
}
}
}
}
}
}
}
]
}
}
}
I getting the below result from the error_list input
But when I am using that list in the terms to filter
{
"terms": {
"error_code_id": [
"{{ctx.payload.error_list._value}}"
]
}
}
I am getting filter like this-
Kindly guide what needs to be changed