How to statically generate a script in Logstash 7.17
Hi, I would like to add elements to nested
in elasticsearch via script via Logstash.
Currently, compilations
, cache_evisions
are increasing.
I also increased max_compilations_rate
.
PUT _cluster/settings
{
"transient": {
"script.max_compilations_rate": "100000/1m"
}
}
Currently, there are N nodes and each node has compilations
and cache_evictions
values.
We know that these values are initialized when a node reboots.
"nodes" : {
"1" : {
"script" : {
"compilations" : 1042572,
"cache_evictions" : 1042472,
"compilation_limit_triggered" : 0
}
},
"2" : {
"script" : {
"compilations" : 1059702,
"cache_evictions" : 1059602,
"compilation_limit_triggered" : 0
}
},
.
.
}
This seems to have a bad effect on the cluster.
Is there any way to use static scripts ?
Below is the current Logstash code.
elasticsearch {
id => "begins"
hosts => ["http://10.10.155.193:9210"]
index => "%{[@metadata][_index_name]}"
document_id => "%{[@metadata][_id]}"
routing => "%{[@metadata][_routing_id]}"
action => "update"
doc_as_upsert => false
script => "
if (ctx._source.temp_wtime != null) {
if (ctx._source.begin_wtime == null) {
ctx._source.begin_wtime = new ArrayList();
}
if (ctx._source.begin_wtime instanceof Collection) {
if (!ctx._source.begin_wtime.contains('%{wtime}')) {
ctx._source.begin_wtime.add('%{wtime}');
}
} else {
ctx._source.begin_wtime = ['%{wtime}'];
}
ctx._source.begin_count = ctx._source.begin_wtime.size();
}
"
script_lang => "painless"
}
Thank you