Version Used:
Logstash 5.5.0
Data Flow -> Filebeat (5.5.0)_ Logstash 5.5.0_Elasticsearch 5.5.0
Input Case1:
<tag1></tag1><tag2></tag2><Unique>Data 1<Unique> <tag3></tag3><tag4></tag4>
Input Case 2:
<tag1></tag1><tag2></tag2><Distinct Tag="1">Data 2</Distinct> <tag3></tag3><tag4></tag4>
Input Case 3:
<tag1></tag1><tag2></tag2><Unique>Data 1</Unique> <tag3></tag3><tag4></tag4><Distinct Tag="1">Data 2</Distinct> <tag5></tag5>
Logstash Filter
Expected Output : Extract "Unique" tag Data, if it is not present then extract "Distinct Tag="1" tagdata
Logstash Yml:
filter { grok { patterns_dir => "./patterns" match => ["message", "<Unique>%{GREEDYDATA:Product_ID}</Unique>"] } if [Product_ID] ==[]{ grok { patterns_dir => "./patterns" match => ["message", '<Distinct Tag="1" %{DATA:namespace}>%{GREEDYDATA:Product_ID}</Distinct>'] } } } } filter { if "_grokparsefailure" in [tags] { drop { } }
Current Output :
The second match never occurs. (Distinct Tag="1" )
Case 2 Fails. If Distinct Tag is used in one grok separately, it work.
I even tried ->
if ![Product_ID]
#still not working