Painless script error "Unsupported script value"

Hello,

I'm new with kibana, elasticsearch and painles.
I try to get my real memory usage of my Redhat server.

So I create a scripted field with this painless script :

float a; 
float b; 

if (doc['system.memory.actual.used.bytes'].size() == 0) {return '';}
if ((doc['system.memory.actual.used.bytes'].value == 'Deny') || (doc['system.memory.actual.used.bytes'].value == 'denied') || (doc['system.memory.actual.used.bytes'].value == 'denied by ACL') || (doc['system.memory.actual.used.bytes'].value == 'Denied')) { return 'Deny'; }

if (doc['system.memory.total'].size() == 0) {return '';}
if ((doc['system.memory.total'].value == 'Deny') || (doc['system.memory.total'].value == 'denied') || (doc['system.memory.total'].value == 'denied by ACL') || (doc['system.memory.total'].value == 'Denied')) { return 'Deny'; }

a = doc['system.memory.actual.used.bytes'].value / 1024 / 1024;
b = doc['system.memory.total'].value / 1024 / 1024;

return a / b;

So, when I try to use it in visualization, here the error I get :

[esaggs] > Request to Elasticsearch failed:{"error":{"root_cause":[{"type":"aggregation_execution_exception","reason":"Unsupported script value , expected a number, date, or boolean"}],"type":"search_phase_execution_exception","reason":"all shards failed","phase":"query","grouped":true,"failed_shards":[{"shard":0,"index":"metricbeat-7.4.2-2019.12.03-000001","node":"AAgahLHeSLGGF-ADwfLLeg","reason":{"type":"aggregation_execution_exception","reason":"Unsupported script value , expected a number, date, or boolean"}}]},"status":500}

I understand that the value that expected should be a number, a date or a boolean. So I modify the type of my variables to put a int instead of a float but nothing happen...

Do you know where is my error ?

Thanks.

Ok I found my problem.

I've a service which return nothing for doc['system.memory.actual.used.bytes'].
So in my initial script I return an empty value at the line :

if (doc['system.memory.actual.used.bytes'].size() == 0) {return '';}

So I changed what I return to put a boolean and now it's works !!

Hope it will help someone here

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.