hi...
I need to extract from a path certain value by position...
example:
let's say I split this following path into array using '\' as split char
E:\OUM82\APP\Logs\UploadManager_20062019.log
I get:
[0]=E:
[1]=OUM82
[2]=APP
[3]=logs
[4]=UploadManager_20062019.log
so,
I'm always want to take whatever in [2]
how do I implement it?
You cannot do it with mutate+split (which is what I would normally suggest) due to this issue, which affects regexps, single quoted string, and double quoted strings.
It is possible using grok if you enable config.support_escapes on logstash.yml... Believe it or not
grok { match => { "path" => "^(?<pathDriveSign>\w{1}):\\\\(?<RootFolder>[^\\\\]+)\\\\(?<customerFolder>[^\\\\]+)\\\\." } }
Do not ask me to explain why 4 backslashes are required to represent a single backslash.
There is also a sneaky way to do it in ruby. You cannot have a backslash at the end of a string, so we have a string that contains a backslash and extract the backslash from it.
Apache, Apache Lucene, Apache Hadoop, Hadoop, HDFS and the yellow elephant
logo are trademarks of the
Apache Software Foundation
in the United States and/or other countries.