Detailed info:
Errors + logs from my application goes to logstash in JSON format. From Logstash, the messages are stored in elasticsearch. I am running watcher on elastic search. If the condition "watcher_id" is "test", then action can be triggered at 10second interval. The action is webhook. I want to send json data in webhook to remote Django rest server. As per the below configuration, the rest request goes to django rest server goes. But Django rest server returns back 404 error to the watcher. I could see this in output of watcher records. Sample output is given in output part(2)
Even though I gave header as json in action, the django rest server interpreted as text/html. The django rest server has model defined with watcher_id as primary field. There is no error in django rest server. I could admin GUI and post data in django admin GUI.
I tried different combinations for body field to send in json from watcher webhook action. But nothing is successful.
output part (1)
{
"trigger": {
"schedule": {
"interval": "10s"
}
},
"input": {
"search": {
"request": {
"indices": [
"mysecond"
],
"body": {
"query": {
"match": {
"watcher_id": "test"
}
}
}
}
}
},
"condition": {
"compare": {
"ctx.payload.hits.total": {
"gt": 0
}
}
},
"actions": {
"my_webhook": {
"webhook": {
"method": "POST",
"host": "10.225.117.135",
"port": 8001,
"path": "/gen/api/v1/watch",
"headers": {
"Authorization": "Bearer ROOM_TOKEN",
"Content-Type": "application/json"
},
"body": "watcher_id: {{ctx.payload.hits.total}}"
}
}
}
}
output part (2)
"actions": [
{
"id": "my_webhook",
"type": "webhook",
"status": "failure",
"reason": "received [404] status code",
"webhook": {
"request": {
"host": "10.225.117.135",
"port": 8001,
"scheme": "http",
"method": "post",
"path": "/gen/api/v1/watch",
"headers": {
"Authorization": "Bearer ROOM_TOKEN",
"Content-Type": "application/json"
},
"body": "watcher_id: 940"
},
"response": {
"status": 404,
"headers": {
"content-type": [
"text/html"
],
"server": [
"WSGIServer/0.1 Python/2.7.6"
],
"date": [
"Mon, 13 Jun 2016 17:50:36 GMT"
],
"vary": [
"Cookie"
]
}
}
}
}
]