Kibana 5 scripted field for regex match


(ramjive) #1

Below is the 1st of the document which contains field name "message" which has value in a form of text.

// message Reconciliation for plan 141 - Line 3 is completed

Below is the second document which contains field name "message" which has value as,

// message Reconciliation for plan 141 - Line 3 is Started

Now the requirement is to compare the both of the document field values , if " line 3 is started" and ends with "completed". It has to be returned true and if the message returned as "Line 3 is FAILED", then it has to return false and also in the message you can see that "Plan 141 Line3", The plan number differs and id number keeps changing for different document. This is the scenario in which i have to compare the field values. Let me know if it can be compared even after the number changes also, if not compare only the string values "is started" and "is completed"

Things I tried:

<
def m = /^.*.([a-z]+)$/.matcher(doc['message'].value);
if ( m.matches("Started") ) {
return "true"
} else if ( m.matches("Completed") ){
return "false"
}
else {
return "no match"
}
/>
The above query return an empty array in scripted field in kibana. I don't know why

These things are not returning me what I wanted. I'm missing something.

I tried in painlesscripting in the scripted fields but is not working.

If it cannot be compared with dynamic values, atleast I need to compare the field values "started" and "completed" first.


(system) #2

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