Open kronenpj opened 7 years ago
@kronenpj Your rule is syntactically incorrect.
Try this one:
rule "SELinux AVC Extraction"
when
has_field("file") && to_string($message.file) == "/var/log/audit/audit.log"
then
let matches = grok("%{avc_extractor}", $message.message);
set_fields(matches);
end
This being said, a syntactically incorrect rule should never trigger a NullPointerException but a emit parse error instead.
Graylog Version: 2.4.0-beta3 (also 2.3.1)
There is no Graylog 2.4.0-beta3 (yet).
Quite right, alpha-3...
I hadn't thought to try the let/set_fields combination. I'm sure that'll work. Thanks!
For posterity, joschi's suggestion was very slightly incorrect. This syntax was accepted by the parser:
rule "SELinux AVC Extraction"
when
has_field("file") && to_string($message.file) == "/var/log/audit/audit.log"
then
let matches = grok("%{avc_extractor}", to_string($message.message));
set_fields(matches);
end
Also, I should note that the wildly incorrect code I originally posted did not flag an error in the UI's syntax checker.
@joschi @jalogisch It doesn't produce an error anymore, but also doesn't produce a syntax error either.
Version: 3.2.4+a407287, codename Ethereal Elk JVM: Oracle Corporation 1.8.0_242 on Linux 4.9.0-12-amd64
rule "stunnel service message"
when
has_field("application_name")
&& to_string($message.application_name) == "stunnel"
&& NOT has_field("processed")
then
let stunnel_message = to_string($message.message);
let parsed_pattern = grok("STUNNELSERVICE", stunnel_message, true);
set_fields(parsed_pattern);
set_field("processed", true);
end
It only adds the processed field.
@braiam you have reverenced the Pattern the wrong way, that is why the pattern is not used to extract fields.
We are using GitHub issues for tracking bugs in Graylog itself, but this doesn't look like one. Please post this issue to our discussion forum or join the #graylog channel on freenode IRC.
Thank you!
@jalogisch I know I did it the wrong way, but @joschi said "This being said, a syntactically incorrect rule should never trigger a NullPointerException but a emit parse error instead". Graylog still doesn't emit a parse error and that feature is missing. The bug report isn't closed yet, so I presume that that's being still worked on, since the NPE has been addressed.
If not, this bug is already fixed. The wrong syntax don't trigger a NPE.
While attempting to add a pipeline rule, the UI emits the red error banner saying: Saving rule "" failed with status: cannot POST http://10.0.0.2:9000/api/plugins/org.graylog.plugins.pipelineprocessor/system/pipelines/rule (500)
Attempted rule addition:
The 'avc_extractor' grok was already loaded into Graylog.
Expected Behavior
Assuming syntax of pipeline rule is correct, accept the rule and make available via UI.
Current Behavior
While attempting to add a pipeline rule, the UI emits the red error banner saying: Saving rule "" failed with status: cannot POST http://10.0.0.2:9000/api/plugins/org.graylog.plugins.pipelineprocessor/system/pipelines/rule (500)
Graylog log file contains:
Possible Solution
Sorry, can't help here.
Steps to Reproduce (for bugs)
Context
The grok is intended to parse the SELinux AVC messages collected from /var/log/audit/audit.log into usable fields. The pipeline rule would invoke the grok on appropriate messages.
Your Environment
Also tried adding the rule via API Browser with the same result.