如何将有效负载作为输入传递给 ELK 观察程序中的“转换”过程?我尝试过以下方式,但它将它们作为字符串传递给 groovy 文件。
"transform": {
"script": {
"file": "error_parser",
"lang": "groovy",
"params": {
"inputval": "{{ctx.payload.aggregations.errorcount.buckets}}"
}
}
}
当我想传递一个字符串或整数时,我没有遇到任何问题,而是对象。有没有办法将它们传递给文件?在这种情况下,我们从 groovy 脚本返回的输出值存储在哪里(“条件”过程在类似情况下将输出评估为布尔值)?
时髦的内容:
println inputval
return inputval[0].doc_count
执行观察程序时出现以下错误
{{ctx.payload.aggregations.errorcount.buckets}}
[2016-03-22 17:23:08,637][ERROR][watcher.transform.script ] [Hannah Levy] failed to execute [script] transform for [my-watch_2-2016-03-22T21:23:08.617
Z]
ScriptException[failed to run file script [error_parser] using lang [groovy]]; nested: MissingPropertyException[No such property: doc_count for class:
java.lang.String];
at org.elasticsearch.script.groovy.GroovyScriptEngineService$GroovyScript.run(GroovyScriptEngineService.java:318)
at org.elasticsearch.watcher.transform.script.ExecutableScriptTransform.doExecute(ExecutableScriptTransform.java:73)
at org.elasticsearch.watcher.transform.script.ExecutableScriptTransform.execute(ExecutableScriptTransform.java:59)
at org.elasticsearch.watcher.transform.script.ExecutableScriptTransform.execute(ExecutableScriptTransform.java:40)