-
Notifications
You must be signed in to change notification settings - Fork 5k
Filebeat: ingest Elasticsearch structured audit logs #8852
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
Merged
ycombinator
merged 21 commits into
elastic:6.x
from
ycombinator:filebeat-elasticsearch-structured-audit-log
Jan 26, 2019
Merged
Changes from all commits
Commits
Show all changes
21 commits
Select commit
Hold shift + click to select a range
f06e2ff
Amending pipeline to handle structured logs
ycombinator 36f9ba0
Adding globs for structured audit log files
ycombinator b4ba744
Fixing up pipeline
ycombinator c99efdd
Fixing up log fixture
ycombinator dad4795
Only build URI field if it's not going to be empty
ycombinator 73e7219
Fixing up log fixture
ycombinator 5888ace
Updating fields.ymls
ycombinator ec290bd
Splitting test logs and expected files
ycombinator 30d23f9
Fixing up test fixtures
ycombinator 87452c1
Reverting content in original expected test file
ycombinator 79e5d88
Fixing offsets after splitting files
ycombinator bbc5d39
Updating generated files
ycombinator 700291c
Fixing up pipeline
ycombinator b3d899e
Regenerating golden files
ycombinator 527d057
Using multiple pipelines
ycombinator cdf7046
Regenerating golden files
ycombinator c381143
Adding CHANGELOG entries
ycombinator 2b4c477
Regenerating generated files
ycombinator 04657ed
Updating golden files for 6.x
ycombinator 79765ad
Removing file accidentally ported over from master
ycombinator 2667c21
Rebasing...
ycombinator File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
190 changes: 190 additions & 0 deletions
190
filebeat/module/elasticsearch/audit/ingest/pipeline-json.json
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,190 @@ | ||
| { | ||
| "description": "Pipeline for parsing elasticsearch audit logs in JSON format", | ||
| "processors": [ | ||
| { | ||
| "json": { | ||
| "field": "message", | ||
| "target_field": "elasticsearch.audit" | ||
| } | ||
| }, | ||
| { | ||
| "dot_expander": { | ||
| "field": "event.action", | ||
| "path": "elasticsearch.audit" | ||
| } | ||
| }, | ||
| { | ||
| "rename": { | ||
| "field": "elasticsearch.audit.event.action", | ||
| "target_field": "elasticsearch.audit.event_type" | ||
| } | ||
| }, | ||
| { | ||
| "dot_expander": { | ||
| "field": "event.type", | ||
| "path": "elasticsearch.audit" | ||
| } | ||
| }, | ||
| { | ||
| "rename": { | ||
| "field": "elasticsearch.audit.event.type", | ||
| "target_field": "elasticsearch.audit.layer" | ||
| } | ||
| }, | ||
| { | ||
| "remove": { | ||
| "field": "elasticsearch.audit.event" | ||
| } | ||
| }, | ||
| { | ||
| "dot_expander": { | ||
| "field": "origin.type", | ||
| "path": "elasticsearch.audit" | ||
| } | ||
| }, | ||
| { | ||
| "rename": { | ||
| "field": "elasticsearch.audit.origin.type", | ||
| "target_field": "elasticsearch.audit.origin_type" | ||
| } | ||
| }, | ||
| { | ||
| "dot_expander": { | ||
| "field": "origin.address", | ||
| "path": "elasticsearch.audit" | ||
| } | ||
| }, | ||
| { | ||
| "grok": { | ||
| "field": "elasticsearch.audit.origin.address", | ||
| "patterns": [ | ||
| "\\[%{IPORHOST:elasticsearch.audit.origin_address}\\]:%{INT:elasticsearch.audit.origin_port:int}", | ||
| "%{IPORHOST:elasticsearch.audit.origin_address}:%{INT:elasticsearch.audit.origin_port:int}" | ||
| ] | ||
| } | ||
| }, | ||
| { | ||
| "remove": { | ||
| "field": "elasticsearch.audit.origin" | ||
| } | ||
| }, | ||
| { | ||
| "dot_expander": { | ||
| "field": "user.name", | ||
| "path": "elasticsearch.audit" | ||
| } | ||
| }, | ||
| { | ||
| "rename": { | ||
| "field": "elasticsearch.audit.user.name", | ||
| "target_field": "elasticsearch.audit.principal" | ||
| } | ||
| }, | ||
| { | ||
| "dot_expander": { | ||
| "field": "request.name", | ||
| "path": "elasticsearch.audit" | ||
| } | ||
| }, | ||
| { | ||
| "set": { | ||
| "value": "{{elasticsearch.audit.request.name}}", | ||
| "field": "elasticsearch.audit.request" | ||
| } | ||
| }, | ||
| { | ||
| "remove": { | ||
| "if": "ctx.elasticsearch.audit.request == ''", | ||
| "field": "elasticsearch.audit.request" | ||
| } | ||
| }, | ||
| { | ||
| "dot_expander": { | ||
| "field": "url.path", | ||
| "path": "elasticsearch.audit" | ||
| } | ||
| }, | ||
| { | ||
| "dot_expander": { | ||
| "field": "url.query", | ||
| "path": "elasticsearch.audit" | ||
| } | ||
| }, | ||
| { | ||
| "set": { | ||
| "if": "ctx.elasticsearch.audit?.url?.path != null && ctx.elasticsearch.audit?.url?.query == null", | ||
| "field": "elasticsearch.audit.uri", | ||
| "value": "{{elasticsearch.audit.url.path}}" | ||
| } | ||
| }, | ||
| { | ||
| "set": { | ||
| "if": "ctx.elasticsearch.audit?.url?.path != null && ctx.elasticsearch.audit?.url?.query != null", | ||
| "field": "elasticsearch.audit.uri", | ||
| "value": "{{elasticsearch.audit.url.path}}?{{elasticsearch.audit.url.query}}" | ||
| } | ||
| }, | ||
| { | ||
| "remove": { | ||
| "if": "ctx.elasticsearch.audit?.url?.path != null", | ||
| "field": "elasticsearch.audit.url.path" | ||
| } | ||
| }, | ||
| { | ||
| "remove": { | ||
| "if": "ctx.elasticsearch.audit?.url?.query != null", | ||
| "field": "elasticsearch.audit.url.query" | ||
| } | ||
| }, | ||
| { | ||
| "dot_expander": { | ||
| "field": "node.id", | ||
| "path": "elasticsearch.audit" | ||
| } | ||
| }, | ||
| { | ||
| "dot_expander": { | ||
| "field": "node.name", | ||
| "path": "elasticsearch.audit" | ||
| } | ||
| }, | ||
| { | ||
| "rename": { | ||
| "field": "elasticsearch.audit.node", | ||
| "target_field": "elasticsearch.node" | ||
| } | ||
| }, | ||
| { | ||
| "dot_expander": { | ||
| "field": "user.realm", | ||
| "path": "elasticsearch.audit" | ||
| } | ||
| }, | ||
| { | ||
| "rename": { | ||
| "if": "ctx.elasticsearch.audit?.user?.realm != null", | ||
| "field": "elasticsearch.audit.user.realm", | ||
| "target_field": "elasticsearch.audit.user_realm" | ||
| } | ||
| }, | ||
| { | ||
| "dot_expander": { | ||
| "field": "user.roles", | ||
| "path": "elasticsearch.audit" | ||
| } | ||
| }, | ||
| { | ||
| "remove": { | ||
| "field": "elasticsearch.audit.user" | ||
| } | ||
| } | ||
| ], | ||
| "on_failure": [ | ||
| { | ||
| "set": { | ||
| "field": "error.message", | ||
| "value": "{{ _ingest.on_failure_message }}" | ||
| } | ||
| } | ||
| ] | ||
| } | ||
63 changes: 63 additions & 0 deletions
63
filebeat/module/elasticsearch/audit/ingest/pipeline-plaintext.json
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,63 @@ | ||
| { | ||
| "description": "Pipeline for parsing elasticsearch audit logs in plaintext format", | ||
| "processors": [ | ||
| { | ||
| "grok": { | ||
| "field": "message", | ||
| "pattern_definitions": { | ||
| "ES_TIMESTAMP": "\\[%{TIMESTAMP_ISO8601:elasticsearch.audit.@timestamp}\\]", | ||
| "ES_NODE_NAME": "(\\[%{DATA:elasticsearch.node.name}\\])?", | ||
| "ES_AUDIT_LAYER": "\\[%{WORD:elasticsearch.audit.layer}\\]", | ||
| "ES_AUDIT_EVENT_TYPE": "\\[%{WORD:elasticsearch.audit.event_type}\\]", | ||
| "ES_AUDIT_ORIGIN_TYPE": "(origin_type\\=\\[%{WORD:elasticsearch.audit.origin_type}\\])?", | ||
| "ES_AUDIT_ORIGIN_ADDRESS": "(origin_address\\=\\[%{IPORHOST:elasticsearch.audit.origin_address}\\])?", | ||
| "ES_AUDIT_PRINCIPAL": "(principal\\=\\[%{WORD:elasticsearch.audit.principal}\\])?", | ||
| "ES_AUDIT_REALM": "(realm\\=\\[%{WORD:elasticsearch.audit.realm}\\])?", | ||
| "ES_AUDIT_ROLES": "(roles\\=\\[%{DATA:elasticsearch.audit.roles}\\])?", | ||
| "ES_AUDIT_ACTION": "(action\\=\\[%{DATA:elasticsearch.audit.action}(\\[%{DATA:elasticsearch.audit.sub_action}\\])?\\])?", | ||
| "ES_AUDIT_URI": "(uri=\\[%{DATA:elasticsearch.audit.uri}\\])?", | ||
| "ES_AUDIT_INDICES": "(indices\\=\\[%{DATA:elasticsearch.audit.indices}\\])?", | ||
| "ES_AUDIT_REQUEST": "(request\\=\\[%{WORD:elasticsearch.audit.request}\\])?", | ||
| "ES_AUDIT_REQUEST_BODY": "(request_body\\=\\[%{DATA:elasticsearch.audit.request_body}\\])?" | ||
| }, | ||
| "patterns": [ | ||
| "%{ES_TIMESTAMP}\\s*%{ES_NODE_NAME}\\s*%{ES_AUDIT_LAYER}\\s*%{ES_AUDIT_EVENT_TYPE}\\s*%{ES_AUDIT_ORIGIN_TYPE},?\\s*%{ES_AUDIT_ORIGIN_ADDRESS},?\\s*%{ES_AUDIT_PRINCIPAL},?\\s*%{ES_AUDIT_REALM},?\\s*%{ES_AUDIT_ROLES},?\\s*%{ES_AUDIT_ACTION},?\\s*%{ES_AUDIT_INDICES},?\\s*%{ES_AUDIT_URI},?\\s*%{ES_AUDIT_REQUEST},?\\s*%{ES_AUDIT_REQUEST_BODY},?" | ||
| ] | ||
| } | ||
| }, | ||
| { | ||
| "split": { | ||
| "field": "elasticsearch.audit.roles", | ||
| "separator": ",", | ||
| "ignore_missing": true | ||
| } | ||
| }, | ||
| { | ||
| "split": { | ||
| "field": "elasticsearch.audit.indices", | ||
| "separator": ",", | ||
| "ignore_missing": true | ||
| } | ||
| }, | ||
| { | ||
| "script": { | ||
| "lang": "painless", | ||
| "source": "if (ctx.elasticsearch.audit.sub_action != null) { ctx.elasticsearch.audit.action += '[' + ctx.elasticsearch.audit.sub_action + ']' }" | ||
| } | ||
| }, | ||
| { | ||
| "remove": { | ||
| "field": "elasticsearch.audit.sub_action", | ||
| "ignore_missing": true | ||
| } | ||
| } | ||
| ], | ||
| "on_failure": [ | ||
| { | ||
| "set": { | ||
| "field": "error.message", | ||
| "value": "{{ _ingest.on_failure_message }}" | ||
| } | ||
| } | ||
| ] | ||
| } |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is only need to make the event look nicer?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No, actually (and unfortunately IMO), it is required for the next processor (
rename) to work. If I remove thisdot_expanderprocessor entry, I will get an error like so from ES when it tries to execute therenameprocessor:Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Perhaps we should file an enhancement request around this with ES?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
elastic/elasticsearch#37507