Scripted Field in Data Table

Hello, I'm working with data tables in kibana and would like to create an additional column from a script. The following script is working

{ "script" : 
    "if (doc['cpu.used.pct'].value > 100) { return 1 }"

But I would like to create a new field of type string. The following script is not working and returns:

class_cast_exception: class java.lang.String cannot be cast to class java.lang.Number (java.lang.String and java.lang.Number are in module java.base of loader 'bootstrap')

{ "script" : 
    "if (doc['cpu.used.pct'].value > 100) { return \"CRITICAL\" }"

Is there a way to achieve the result?

The error seems caused by that you tried to insert string value to numerical field. You have to direct to text field if you want to return string data.

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