Kibana Scripted - How to get a string between the second and the third slash

Hey Guys, I am trying to get a string from a file path field in Kibana. I am not quite sure how to go about it.


The first two slashes are constant however, the slashes after [application] can be dynamic. For example, it can be


I want to extract [application] from the file paths.

Thanks for the help

One way is to split on / and return the 3rd element.



String[] parts = /\//.split("C:/path/[application]/file.log");

return parts[2];



Thanks Aaron, I have tried using this script but it is not working for me. Is there anything I am doing wrong here?

def path = doc['log.file.path'].value;
String[] parts = path.split("\\/");
return parts[2];

Try this.

String[] parts = /\//.split(doc['log.file.path'].value);
return parts[2];

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