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.
C:/path/[application]/file.log.
The first two slashes are constant however, the slashes after [application] can be dynamic. For example, it can be
C:/path/[application]/v/2/file.log
I want to extract [application] from the file paths.
Thanks for the help
One way is to split on /
and return the 3rd element.
C:/path/[application]/file.log
0_/1___/2____________/3_______
Script
String[] parts = /\//.split("C:/path/[application]/file.log");
return parts[2];
Outputs
[application]
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];
system
(system)
Closed
March 15, 2021, 7:35pm
5
This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.