Hello - I would like to create a new field named "process_name". I would like to use part of the an existing field's value to add to the newly created field. Ex:
in the json filter? Also, instead of using a separate mutate you can add the remove_field option to the json filter. That way it only gets removed if it is parsed successfully.
You can use grok to extract the process path. I haven't tested it, but something like
grok { match => { "process_path" => "\\(?<process_name>[^\\]+)$" } }
You may need to play around with the number of backslashes in each place (2, 4, ..).
@Badger - Thanks for taking the time to help me with this. I took your suggestions and made the following changes to my filter and I am seeing some progress:
@Badger - I still want to keep the field name "process_path" and its associated value but I would also like to create a new field named "process_name" but only use the last portion of the process_path value as the process_name value.
That's hard to believe unless you are getting a _grokparsefailure, but the doubling up of process_path tells you are not getting a parse failure.
Note that the UNIXPATH pattern can be very, very expensive. That is why I suggested anchoring to end-of-string and using a character group that excludes the directory separator. Try
@Badger - I am now seeing the new field "process_name" being created. I noticed that there is a change to the "process_path" field and the last portion is being dropped from its value. Not a huge deal but was just wondering if there was a way to keep that field to show the full path and also how do I account for events that do not have the "process_path" field and are resulting in grokparsefailure tags? The grokparsefailure isn't a huge issue because the logs are still being parsed but since they don't have the field process_path that's why its receiving that tag(in my humble opinion).
@Badger - yeah I gave that a try before I replied but it lists an array for the value. I can live with the current results I am getting at this point. Thanks for all your help.
@Badger - I re-read your latest reply and realized I read it incorrectly. After making the change you recently suggested its working as should. thanks again. Final config listed below just incase anybody has the same issue:
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.