-
Notifications
You must be signed in to change notification settings - Fork 5k
Ingest ES structured audit logs #10352
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
Changes from all commits
e9e01be
08cda85
01eed12
b19e4ee
ab7cf63
84ae341
cd1018b
0b11092
1692e94
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,132 @@ | ||
| { | ||
| "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": "event.action" | ||
| } | ||
| }, | ||
| { | ||
| "dot_expander": { | ||
| "field": "event.type", | ||
| "path": "elasticsearch.audit" | ||
| } | ||
| }, | ||
| { | ||
| "rename": { | ||
| "field": "elasticsearch.audit.event.type", | ||
| "target_field": "elasticsearch.audit.layer" | ||
| } | ||
| }, | ||
| { | ||
| "dot_expander": { | ||
| "field": "origin.address", | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I would instead rename this field to |
||
| "path": "elasticsearch.audit" | ||
| } | ||
| }, | ||
| { | ||
| "grok": { | ||
| "field": "elasticsearch.audit.origin.address", | ||
| "patterns": [ | ||
| "\\[%{IPORHOST:source.ip}\\]:%{INT:source.port:int}", | ||
| "%{IPORHOST:source.ip}:%{INT:source.port:int}" | ||
| ] | ||
| } | ||
| }, | ||
| { | ||
| "rename": { | ||
| "field": "elasticsearch.audit.origin.address", | ||
| "target_field": "source.address" | ||
| } | ||
| }, | ||
| { | ||
| "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": "url.original", | ||
| "value": "{{elasticsearch.audit.url.path}}" | ||
| } | ||
| }, | ||
| { | ||
| "set": { | ||
| "if": "ctx.elasticsearch.audit?.url?.path != null && ctx.elasticsearch.audit?.url?.query != null", | ||
| "field": "url.original", | ||
| "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.name", | ||
| "path": "elasticsearch.audit" | ||
| } | ||
| }, | ||
| { | ||
| "rename": { | ||
| "field": "elasticsearch.audit.user.name", | ||
| "target_field": "user.name" | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Can't we dot_expand in place? If the original key is "user.name", I would think that the output to It would simplify the code in a few places where you have the same pattern happening.
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I'm not sure I follow what you mean by doing "dot_expand in place"? The to: That then allows us to call the
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I haven't used { "dot_expander": { "field": "user.name" } }And in cases where the output isn't the object equivalent of the dotted notation, you would use { "dot_expander": { "field": "node.name", "path": "elasticsearch.node" } }If that's not the case, you can ignore this ;-) |
||
| } | ||
| } | ||
| ], | ||
| "on_failure": [ | ||
| { | ||
| "set": { | ||
| "field": "error.message", | ||
| "value": "{{ _ingest.on_failure_message }}" | ||
| } | ||
| } | ||
| ] | ||
| } | ||
| 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:event.type}\\]", | ||
| "ES_AUDIT_ORIGIN_TYPE": "(origin_type\\=\\[%{WORD:elasticsearch.audit.origin.type}\\])?", | ||
| "ES_AUDIT_ORIGIN_ADDRESS": "(origin_address\\=\\[%{IPORHOST:source.ip}\\])?", | ||
| "ES_AUDIT_PRINCIPAL": "(principal\\=\\[%{WORD:user.name}\\])?", | ||
| "ES_AUDIT_REALM": "(realm\\=\\[%{WORD:elasticsearch.audit.user.realm}\\])?", | ||
| "ES_AUDIT_ROLES": "(roles\\=\\[%{DATA:elasticsearch.audit.user.roles}\\])?", | ||
| "ES_AUDIT_ACTION": "(action\\=\\[%{DATA:elasticsearch.audit.action}(\\[%{DATA:elasticsearch.audit.sub_action}\\])?\\])?", | ||
| "ES_AUDIT_URI": "(uri=\\[%{DATA:url.original}\\])?", | ||
| "ES_AUDIT_INDICES": "(indices\\=\\[%{DATA:elasticsearch.audit.indices}\\])?", | ||
| "ES_AUDIT_REQUEST": "(request\\=\\[%{WORD:elasticsearch.audit.request.name}\\])?", | ||
| "ES_AUDIT_REQUEST_BODY": "(request_body\\=\\[%{DATA:http.request.body.content}\\])?" | ||
| }, | ||
| "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.user.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 }}" | ||
| } | ||
| } | ||
| ] | ||
| } |
Uh oh!
There was an error while loading. Please reload this page.