Hi,
I want to monitor when the number of filebeat agents changes. I prefer that instead of a log action or a mail action that it is indexed to the nagios index. I have a script that reads out the nagios index and then magic operation stuff happens.
Now I want to add some fields when the index action is executed
fields:
"nagios_color" : "yellow"
"nagios_msg" : "The number of filebeat agents is {{ctx.payload.aggregations.type_count.value}}"
I think this is done by the transform block but I haven't gotten it working yet. Any one has an idea since the examples in the documentation are not very clear on how you do this.
do I just add
"transform" : {
"script": "return [ nagios_color: yellow]"
}
my watch:
{
"trigger": {
"schedule": {
"interval": "1m"
}
},
"input": {
"search": {
"request": {
"search_type": "query_then_fetch",
"indices": [
".monitoring-beats-6-*"
],
"types": [],
"body": {
"size": 0,
"aggs": {
"type_count": {
"cardinality": {
"field": "beats_stats.beat.name"
}
}
}
}
}
}
},
"condition": {
"compare": {
"ctx.payload.aggregations.type_count.value": {
"not_eq": 28
}
}
},
"actions": {
"log": {
"logging": {
"level": "warn",
"text": "The number of filebeat agents is {{ctx.payload.aggregations.type_count.value}}"
}
},
"index_payload": {
"index": {
"index": "<nagios-{now/M}>",
"doc_type": "_doc",
"execution_time_field": "trigger_event.triggered_time"
}
}
}
}