Yes you' re right Alex.
But even with the "_" the watcher is not created.
With this watcher configuration:
PUT _watcher/watch/pricealert
{
"trigger": {
"schedule": {
"interval": "1m"
}
},
"input": {
"chain": {
"inputs": [
{
"first": {
"search": {
"request": {
"indices": [
"price-request-2020.01.28"
],
"body": {
"size": 10,
"query": {
"match_all": {}
}
}
}
}
}
},
{
"second": {
"search": {
"request": {
"indices": [
"mktdata-2020.01.28"
],
"body": {
"size": 10,
"query": {
"match_all": {}
}
}
}
}
}
}
]
}
},
"condition": {
"script": {
"source": "return ctx.payload.first.hits.hits.0._source.spot >= 0.8",
"lang": "painless"
}
},
"actions": {
"log": {
"logging": {
"level": "info",
"text": "spot out of bound!"
}
}
}
}
I get this result:
{
"_id" : "pricealert",
"_version" : 13,
"_seq_no" : 12,
"_primary_term" : 1,
"created" : false
}
Do you know why?
When running with POST method this watch i have also this result:
{
"_id" : "pricealert_77888106-c314-4075-a55e-6a9066ca9d71-2020-01-28T13:13:57.142Z",
"watch_record" : {
"watch_id" : "pricealert",
"node" : "p-BVjNRJT_WIpKDIrre42Q",
"state" : "failed",
"status" : {
"state" : {
"active" : true,
"timestamp" : "2020-01-28T13:10:54.115Z"
},
"actions" : {
"log" : {
"ack" : {
"timestamp" : "2020-01-28T13:10:54.115Z",
"state" : "awaits_successful_execution"
}
}
},
"execution_state" : "failed",
"version" : 13
},
"trigger_event" : {
"type" : "manual",
"triggered_time" : "2020-01-28T13:13:57.142Z",
"manual" : {
"schedule" : {
"scheduled_time" : "2020-01-28T13:13:57.142Z"
}
}
},
"input" : {
"chain" : {
"inputs" : [
{
"first" : {
"search" : {
"request" : {
"search_type" : "query_then_fetch",
"indices" : [
"price-request-2020.01.28"
],
"rest_total_hits_as_int" : true,
"body" : {
"size" : 10,
"query" : {
"match_all" : { }
}
}
}
}
}
},
{
"second" : {
"search" : {
"request" : {
"search_type" : "query_then_fetch",
"indices" : [
"mktdata-2020.01.28"
],
"rest_total_hits_as_int" : true,
"body" : {
"size" : 10,
"query" : {
"match_all" : { }
}
}
}
}
}
}
]
}
},
"condition" : {
"script" : {
"source" : "return ctx.payload.first.hits.hits.0._source.spot >= 0.8",
"lang" : "painless"
}
},
"result" : {
"execution_time" : "2020-01-28T13:13:57.142Z",
"execution_duration" : 3,
"input" : {
"type" : "chain",
"status" : "success",
"payload" : {
"first" : {
"_shards" : {
"total" : 1,
"failed" : 0,
"successful" : 1,
"skipped" : 0
},
"hits" : {
"hits" : [
{
"_index" : "price-request-2020.01.28",
"_type" : "_doc",
"_source" : {
"@timestamp" : "2020-01-28T08:57:34.000Z",
"subject" : "price request",
"lbound" : 0.8,
"ubound" : 1.2
},
"_id" : "dMZe628BDeRluIZM-HR9",
"_score" : 1.0
}
],
"total" : 1,
"max_score" : 1.0
},
"took" : 1,
"timed_out" : false
},
"second" : {
"_shards" : {
"total" : 1,
"failed" : 0,
"successful" : 1,
"skipped" : 0
},
"hits" : {
"hits" : [
{
"_index" : "mktdata-2020.01.28",
"_type" : "_doc",
"_source" : {
"@timestamp" : "2020-01-28T08:56:48.165Z",
"spot" : 1.0,
"oned" : 3.0,
"twod" : 5.0
},
"_id" : "c8Ze628BDeRluIZMFHSD",
"_score" : 1.0
}
],
"total" : 1,
"max_score" : 1.0
},
"took" : 0,
"timed_out" : false
}
},
"chain" : {
"first" : {
"type" : "search",
"status" : "success",
"payload" : {
"_shards" : {
"total" : 1,
"failed" : 0,
"successful" : 1,
"skipped" : 0
},
"hits" : {
"hits" : [
{
"_index" : "price-request-2020.01.28",
"_type" : "_doc",
"_source" : {
"@timestamp" : "2020-01-28T08:57:34.000Z",
"subject" : "price request",
"lbound" : 0.8,
"ubound" : 1.2
},
"_id" : "dMZe628BDeRluIZM-HR9",
"_score" : 1.0
}
],
"total" : 1,
"max_score" : 1.0
},
"took" : 1,
"timed_out" : false
},
"search" : {
"request" : {
"search_type" : "query_then_fetch",
"indices" : [
"price-request-2020.01.28"
],
"rest_total_hits_as_int" : true,
"body" : {
"size" : 10,
"query" : {
"match_all" : { }
}
}
}
}
},
"second" : {
"type" : "search",
"status" : "success",
"payload" : {
"_shards" : {
"total" : 1,
"failed" : 0,
"successful" : 1,
"skipped" : 0
},
"hits" : {
"hits" : [
{
"_index" : "mktdata-2020.01.28",
"_type" : "_doc",
"_source" : {
"@timestamp" : "2020-01-28T08:56:48.165Z",
"spot" : 1.0,
"oned" : 3.0,
"twod" : 5.0
},
"_id" : "c8Ze628BDeRluIZMFHSD",
"_score" : 1.0
}
],
"total" : 1,
"max_score" : 1.0
},
"took" : 0,
"timed_out" : false
},
"search" : {
"request" : {
"search_type" : "query_then_fetch",
"indices" : [
"mktdata-2020.01.28"
],
"rest_total_hits_as_int" : true,
"body" : {
"size" : 10,
"query" : {
"match_all" : { }
}
}
}
}
}
}
},
"actions" :
},
"exception" : {
"type" : "script_exception",
"reason" : "runtime error",
"script_stack" : [
"return ctx.payload.first.hits.hits.0._source.spot >= 0.8",
" ^---- HERE"
],
"script" : "return ctx.payload.first.hits.hits.0._source.spot >= 0.8",
"lang" : "painless",
"caused_by" : {
"type" : "null_pointer_exception",
"reason" : null,
"stack_trace" : """java.lang.NullPointerException
at org.elasticsearch.painless.DefBootstrap$MIC.checkLHS(DefBootstrap.java:385)
at org.elasticsearch.painless.PainlessScript$Script.execute(return ctx.payload.first.hits.hits.0._source.spot >= 0.8:45)
at org.elasticsearch.xpack.watcher.condition.ScriptCondition.doExecute(ScriptCondition.java:60)
at org.elasticsearch.xpack.watcher.condition.ScriptCondition.execute(ScriptCondition.java:55)
at org.elasticsearch.xpack.watcher.execution.ExecutionService.executeInner(ExecutionService.java:513)
at org.elasticsearch.xpack.watcher.execution.ExecutionService.execute(ExecutionService.java:320)
at org.elasticsearch.xpack.watcher.transport.actions.execute.TransportExecuteWatchAction$1.doRun(TransportExecuteWatchAction.java:159)
at org.elasticsearch.common.util.concurrent.AbstractRunnable.run(AbstractRunnable.java:37)
at org.elasticsearch.xpack.watcher.execution.ExecutionService$WatchExecutionTask.run(ExecutionService.java:627)
at org.elasticsearch.common.util.concurrent.ThreadContext$ContextPreservingRunnable.run(ThreadContext.java:703)
at java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)
at java.lang.Thread.run(Unknown Source)
"""
},
"stack_trace" : """ScriptException[runtime error]; nested: NullPointerException;
at org.elasticsearch.painless.PainlessScript.convertToScriptException(PainlessScript.java:94)
at org.elasticsearch.painless.PainlessScript$Script.execute(return ctx.payload.first.hits.hits.0._source.spot >= 0.8:45)
at org.elasticsearch.xpack.watcher.condition.ScriptCondition.doExecute(ScriptCondition.java:60)
at org.elasticsearch.xpack.watcher.condition.ScriptCondition.execute(ScriptCondition.java:55)
at org.elasticsearch.xpack.watcher.execution.ExecutionService.executeInner(ExecutionService.java:513)
at org.elasticsearch.xpack.watcher.execution.ExecutionService.execute(ExecutionService.java:320)
at org.elasticsearch.xpack.watcher.transport.actions.execute.TransportExecuteWatchAction$1.doRun(TransportExecuteWatchAction.java:159)
at org.elasticsearch.common.util.concurrent.AbstractRunnable.run(AbstractRunnable.java:37)
at org.elasticsearch.xpack.watcher.execution.ExecutionService$WatchExecutionTask.run(ExecutionService.java:627)
at org.elasticsearch.common.util.concurrent.ThreadContext$ContextPreservingRunnable.run(ThreadContext.java:703)
at java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)
at java.lang.Thread.run(Unknown Source)
Caused by: java.lang.NullPointerException
at org.elasticsearch.painless.DefBootstrap$MIC.checkLHS(DefBootstrap.java:385)
... 12 more
"""
}
}
}
So my question is : Is a watch not created when there is an error in my configuration?
Best,
Pierre Jutard