I'm having problems formatting the json correctly in the body of a webhook action. I'm trying to index a new document into a different index.
{
"trigger": {
"schedule": {
"interval": "5m"
}
},
"input": {
"search": {
"request": {
"search_type": "query_then_fetch",
"indices": [
"metricbeat-*"
],
"types": [],
"body": {
"query": {
"bool": {
"filter": [
{
"term": {
"host": "{{ctx.metadata.monitor_host}}"
}
},
{
"range": {
"@timestamp": {
"gte": "now-5m",
"lt": "now"
}
}
}
]
}
}
}
}
}
},
"actions": {
"index_healthy": {
"condition": {
"compare": {
"ctx.payload.hits.total": {
"gt": 0
}
}
},
"webhook": {
"method": "POST",
"host": "192.168.100.101",
"port": 9200,
"path": "/health-{now/d}/server/",
"body": "{
\"@timestamp\": \"{{now}}\",
\"host\": \"{{ctx.metadata.monitor_host}}\",
\"healthscore\": 0
}",
"auth": {
"basic": {
"username": "<username>",
"password": "<password>"
}
}
},
"send_email": {
"condition": {
"compare": {
"ctx.payload.hits.total": {
"lte": 0
}
}
},
"throttle_period_in_millis": 1800000,
"transform": {
"search": {
"request": {
"search_type": "query_then_fetch",
"indices": [
"metricbeat-*"
],
"types": [],
"body": {
"size": 0,
"query": {
"bool": {
"filter": {
"term": {
"host": "{{ctx.metadata.monitor_host}}"
}
}
}
}
}
}
}
},
"email": {
"profile": "standard",
"to": [
"admin@example.com"
],
"subject": "ALERT: {{ctx.metadata.monitor_host}} Server Not Responding",
"body": {
"html": "{{ctx.metadata.monitor_host}} Not Responding"
}
}
}
},
"metadata": {
"monitor_host": "serverA.example.com",
"last_period": "5m",
"window_period": "24h"
}
}