-
Notifications
You must be signed in to change notification settings - Fork 25.6k
Closed
Description
Elasticsearch version (bin/elasticsearch --version): 6.5.0
Plugins installed: none
JVM version (java -version):
java version "11" 2018-09-25
Java(TM) SE Runtime Environment 18.9 (build 11+28)
Java HotSpot(TM) 64-Bit Server VM 18.9 (build 11+28, mixed mode)
Description of the problem including expected versus actual behavior:
Referencing stored scripts by id does not work inside watcher actions.
Steps to reproduce:
- Create a stored script
{
"script": {
"lang": "mustache",
"source": "executed at {{ctx.execution_time}}"
}
}
- Create a simple watcher with log action referencing this script:
{
"trigger" : {
"schedule" : { "interval" : "10s" }
},
"input" : {
"http" : {
"request" : {
"host" : "localhost",
"port" : 9200,
"path" : "/_cluster/health"
}
}
},
"actions" : {
"log" : {
"logging" : {
"text" : {
"id" : "log-action"
}
}
}
}
}
In logs you will see:
[2019-03-19T17:11:06,919][INFO ][o.e.x.w.a.l.ExecutableLoggingAction] [eQ3F5fy] log-action
instead of:
[2019-03-19T17:09:05,768][INFO ][o.e.x.w.a.l.ExecutableLoggingAction] [jR_IkMm] executed at 2019-03-19T16:09:05.739Z
This is also reproducible for other actions, such as e-mail.
The issue is not repoducible in Elasticsearch version 6.4.
The cause of the issue is most likely the following PR #33978.
In particular, this fast path triggers
int indexStartMustacheExpression = template.indexOf("{{");
if (indexStartMustacheExpression == -1) {
return template;
}
which treats log-action as a template.