New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

can't get grok extraction to work #30

Closed
lasdem opened this Issue May 13, 2016 · 3 comments

Comments

Projects
None yet
2 participants
@lasdem

lasdem commented May 13, 2016

Problem description

I want to replace all my extractors on the inputs with pipeline extractions.
I know the pattern should work, because it works in the extractor.
Could be related to Issue #21

rule "mongodb extraction"
when 
    has_field("sourcetype") && $message.sourcetype=="mongodb" 
then
    let pattern = "%{TIMESTAMP_ISO8601:timestamp;date;yyyy-MM-dd'T'HH:mm:ss.SSSZ}\s+\w+\s+%{WORD:categorie}\s+\[%{NOTSPACE:component}\]";
    let message_text = to_string($message.message);
    let matches = grok(pattern: pattern, value: message_text);
    set_fields(matches);
end

But I get the following error in the web interface:

token recognition error at: '\'
Undeclared variable categorie in line 5 pos 97
Undeclared variable w in line 5 pos 85
Unknown function s in line 5 pos 88
mismatched input 's' expecting {';', '[', '.', '<=', '>=', '>', '<', '==', '!=', And, Or}
token recognition error at: '%'
Expected type String but found Map when indexing in line 5 pos 91
token recognition error at: '+\'
token recognition error at: '"%{TIMESTAMP_ISO8601:timestamp;date;yyyy-MM-dd'T'HH:mm:ss.SSSZ}\s'
extraneous input 's' expecting {')', '[', ',', '.', '<=', '>=', '>', '<', '==', '!=', And, Or}
token recognition error at: '+%'
Undeclared variable component in line 5 pos 123
token recognition error at: '";\r\n    let message_text = to_string($message.message);\r\n    let matches = grok(pattern: pattern, value: message_text);\r\n    set_fields(matches);\r\nend'
missing '(' at '{'

Environment

Used the yum repository to install/update graylog

  • Graylog Version: 2.0.1 (81e0187)
  • Pipeline Processor plugin version: 1.0.0-beta.3
  • Elasticsearch Version: 2.3.2
  • MongoDB Version: 3.2.6
  • Operating System: RHEL 6.7
  • Browser version: Chrome Version 50.0.2661.102 m
@kroepke

This comment has been minimized.

Member

kroepke commented May 13, 2016

There's is a parser problem with unescaping backslashes, you are right.

Generally backslashes must be escaped, so \s needs to be \\s in the rule source, however it is not always properly unescaped during parsing.
I'm working on a fix.

@kroepke

This comment has been minimized.

Member

kroepke commented May 13, 2016

Please also note that Java's SimpleDateFormat which is used by the Java Grok library, will not work with Z if you send it a literal Z for UTC. In that case you will need to use X instead:

https://docs.oracle.com/javase/7/docs/api/java/text/SimpleDateFormat.html
http://stackoverflow.com/questions/2580925/simpledateformat-parsing-date-with-z-literal

@kroepke

This comment has been minimized.

Member

kroepke commented Jul 20, 2016

This is actually properly fixed by #47

@kroepke kroepke closed this Jul 20, 2016

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment