I am learning about logstash, esspecially about logstash filter with if condition. Something not clear to me is what are those fields used in if condition? How can I get the list of those fields?
For example, I want to apply different grok filter format for logs coming from different hosts. How can i put the condition to match hostname.
Your clarification here is highly appreciated!
Thanks!
There are many ways you could do. You can either do a if/else condition in output or within filter.
I tend to do mostly within filter as it will be cleaner and modular
So, you grok the event first to get the filed and then put the condition based on one of those fields, what if I want to grok based on the hostname from where the event comes, which field that I should use in my condition?
Something like this ?
if "database-server" in [hostname] {
really can't comment on that until I see the payload and fields you have already extracted.
Best thing to do is to see your raw data in Elastic, and then find the field (key-value) which has the "database-server". if it is beats, then it might be host.name or agent.hostname or beat.hostname depending on the version or type of input
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.