You can use a mutate filter with add_field to add the fields with their default values prior to the grok filter, then use the grok filter's overwrite option to tell grok that those fields are okay to overwrite.
But if the value(e.g. f1) is missing then the grok parser will fail and no subsequent fields will be parsed.
And also, is there any way to specify all the fields in strip_field of mutate filter by a single keyword like *.
What I mean to say is if f1 is missing then grok parser will fail and then I will not be able to parse either of subsequent fields like hField1 or hIp1 ,etc which might not be missing from the logs and can be parsed from it.
Okay, but that's a different problem. You can either make parts of the grok expression optional with (...)? or you can list multiple expressions in the same grok filter. They will be tried in order and the first match wins. There's an example in the documentation.
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.