Is the position of (in this case) catch22 always the same within the path? That is, is it always the third path component from the end? Or should we instead count from the beginning of the string.
either
/apps/home/cache22/logs/sixt/rse.16-02-02_09.log
or
/apps/home/cache22/logs/rse.16-02-02_09.log
In my source, cache22 is always the third occurence and the string keeps changing to different values like "cache22" or "hotels" or "rental" etc..but it is always after "/apps/home"
The other thing is there might or might not be a subdirectory after "/logs" in the source... My scenario is like I am streaming log files(.log) under "/logs" and in some of the applications there are additional (.log) inside subdirectories under "/logs" and these subdirectory names keep changine.
So, I need to grok for both "cache22" and also "sixt" (if it exists) else its fine.
In my source, cache22 is always the third occurence and the string keeps changing to different values like "cache22" or "hotels" or "rental" etc..but it is always after "/apps/home"
That's quite easy. The expression
^/apps/home/(?<whatever>[^/]+)/
will capture the third path component (one or more characters except slash) into the whatever field.
The other thing is there might or might not be a subdirectory after "/logs" in the source... My scenario is like I am streaming log files(.log) under "/logs" and in some of the applications there are additional (.log) inside subdirectories under "/logs" and these subdirectory names keep changine.
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.