Corrected. But now I am getting
Watcher: An internal server error occurred
while simulating the watcher.
Because Variable [host_name] is not defined.
Something seems to be wrong but I'm not sure what.
Also, the example mentioned here - https://www.elastic.co/guide/en/x-pack/current/transform-chain.html is missing request
part
Edit 1:
While the above issue is resolved, I am now getting error while parsing heartbeat json. Here's the error:
"exception": {
"type": "script_exception",
"reason": "runtime error",
"script_stack": [
"return ctx.payload.hits.hits._source.http.response.status > params.status",
" ^---- HERE"
],
"script": "return ctx.payload.hits.hits._source.http.response.status > params.status",
"lang": "painless",
"caused_by": {
"type": "illegal_argument_exception",
"reason": "Illegal list shortcut value [_source].",
"stack_trace": "java.lang.IllegalArgumentException: Illegal list shortcut value [_source].\n\tat org.elasticsearch.painless.Def.lookupGetter(Def.java:454)\n\tat org.elasticsearch.painless.DefBootstrap$PIC.lookup(DefBootstrap.java:149)\n\tat org.elasticsearch.painless.DefBootstrap$PIC.fallback(DefBootstrap.java:203)\n\tat org.elasticsearch.painless.PainlessScript$Script.execute(return ctx.payload.hits.hits._source.http.response.status > params.status:29)\n\tat org.elasticsearch.painless.ScriptImpl.run(ScriptImpl.java:105)\n\tat org.elasticsearch.xpack.watcher.condition.ScriptCondition.doExecute(ScriptCondition.java:85)\n\tat org.elasticsearch.xpack.watcher.condition.ScriptCondition.execute(ScriptCondition.java:76)\n\tat org.elasticsearch.xpack.watcher.execution.ExecutionService.executeInner(ExecutionService.java:466)\n\tat org.elasticsearch.xpack.watcher.execution.ExecutionService.execute(ExecutionService.java:317)\n\tat org.elasticsearch.xpack.watcher.transport.actions.execute.TransportExecuteWatchAction$1.doRun(TransportExecuteWatchAction.java:165)\n\tat org.elasticsearch.common.util.concurrent.AbstractRunnable.run(AbstractRunnable.java:37)\n\tat java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511)\n\tat java.util.concurrent.FutureTask.run(FutureTask.java:266)\n\tat org.elasticsearch.common.util.concurrent.ThreadContext$ContextPreservingRunnable.run(ThreadContext.java:573)\n\tat java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)\n\tat java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)\n\tat java.lang.Thread.run(Thread.java:748)\n"
},
"stack_trace": "ScriptException[runtime error]; nested: IllegalArgumentException[Illegal list shortcut value [_source].];\n\tat org.elasticsearch.painless.PainlessScript.convertToScriptException(PainlessScript.java:101)\n\tat org.elasticsearch.painless.PainlessScript$Script.execute(return ctx.payload.hits.hits._source.http.response.status > params.status:8)\n\tat org.elasticsearch.painless.ScriptImpl.run(ScriptImpl.java:105)\n\tat org.elasticsearch.xpack.watcher.condition.ScriptCondition.doExecute(ScriptCondition.java:85)\n\tat org.elasticsearch.xpack.watcher.condition.ScriptCondition.execute(ScriptCondition.java:76)\n\tat org.elasticsearch.xpack.watcher.execution.ExecutionService.executeInner(ExecutionService.java:466)\n\tat org.elasticsearch.xpack.watcher.execution.ExecutionService.execute(ExecutionService.java:317)\n\tat org.elasticsearch.xpack.watcher.transport.actions.execute.TransportExecuteWatchAction$1.doRun(TransportExecuteWatchAction.java:165)\n\tat org.elasticsearch.common.util.concurrent.AbstractRunnable.run(AbstractRunnable.java:37)\n\tat java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511)\n\tat java.util.concurrent.FutureTask.run(FutureTask.java:266)\n\tat org.elasticsearch.common.util.concurrent.ThreadContext$ContextPreservingRunnable.run(ThreadContext.java:573)\n\tat java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)\n\tat java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)\n\tat java.lang.Thread.run(Thread.java:748)\nCaused by: java.lang.IllegalArgumentException: Illegal list shortcut value [_source].\n\tat org.elasticsearch.painless.Def.lookupGetter(Def.java:454)\n\tat org.elasticsearch.painless.DefBootstrap$PIC.lookup(DefBootstrap.java:149)\n\tat org.elasticsearch.painless.DefBootstrap$PIC.fallback(DefBootstrap.java:203)\n\tat org.elasticsearch.painless.PainlessScript$Script.execute(return ctx.payload.hits.hits._source.http.response.status > params.status:29)\n\t... 13 more\n"
}
Here's the json I am trying to parse:
"hits": {
"total": 6120,
"max_score": 0.00008168934,
"hits": [
{
"_index": "heartbeat-6.2.4-2018.05.08",
"_type": "doc",
"_id": "JsIMPWMBT22YMjfjXauE",
"_score": 0.00008168934,
"_source": {
"tcp": {
"rtt": {
"connect": {
"us": 1227
}
},
"port": 80
},
"resolve": {
"ip": "54.319.1.87",
"host": "aaaaaa",
"rtt": {
"us": 6103
}
},
"beat": {
"name": "STOOR",
"hostname": "STOOR",
"version": "6.2.4"
},
"@timestamp": "2018-05-08T00:00:09.367Z",
"type": "monitor",
"http": {
"response": {
"status": 200
},
"rtt": {
"write_request": {
"us": 33
},
"total": {
"us": 2737
},
"response_header": {
"us": 1422
},
"validate": {
"us": 1459
},
"content": {
"us": 37
}
},
"url": "http://aaaaaaaa"
},
"@version": "1",
"host": "STOOR",
"tags": [
"beats_input_raw_event"
],
"monitor": {
"id": "http@http://aaaaaaaa",
"status": "up",
"ip": "54.319.1.87",
"type": "http",
"scheme": "http",
"name": "http",
"duration": {
"us": 8898
},
"host": "aaaaaa"
}
}
},
Note: I've only pasted the relevant json record from the complete output.