Search code examples
regexlogstashlogstash-groklogstash-configuration

Regular Expression matching pattern for cc_digits in logstash configuration


msg field data is:

Starting RentalTransactionMessageProcessor cc_digits="1982"

grok matching pattern is:

grok { 
  match => { "msg" => "%{GREEDYDATA:text} cc_digits= %{NUMBER:ccdigits}" } 
}

Rule:

cc_digits should be 4 digits

I am checking with the below grokDebugger

http://grokconstructor.appspot.com/do/match#result

This is not the correct way of writing the matching pattern.Can anybody provide the correct way of writing pattern.


Solution

  • You forgot the quotes.

    %{GREEDYDATA:text} cc_digits="(?<ccdigits>\d{4})"
    

    edit: Remember to escape the quotes, when you are using this pattern.