i want to set name_of_server in condition area and use it inside logging action.
is this possible?
"actions": {
"my-logging-action": {
"condition":{
"script": {
"source": "
name_of_server='';
for(int i=0; i < ctx.payload.aggregations.range_by_date.buckets[0].blades.buckets.length; i++){
if(ctx.payload.aggregations.range_by_date.buckets[0].blades.buckets[i][ctx.metadata.element].value > params.threshold){
name_of_server = ctx.payload.aggregations.range_by_date.buckets[0].blades.buckets[i][blade_name];
return true;
}
}",
"lang":"painless",
"params": { "threshold": 5 }
}
},
"logging": {
"level": "info",
"text": "{name_of_server} alert"
}
}
}