-
Notifications
You must be signed in to change notification settings - Fork 5k
Ingest structured ES slow logs #10447
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
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,108 @@ | ||
| { | ||
| "description": "Pipeline for parsing the Elasticsearch slow logs in JSON format.", | ||
| "on_failure": [ | ||
| { | ||
| "set": { | ||
| "field": "error.message", | ||
| "value": "{{ _ingest.on_failure_message }}" | ||
| } | ||
| } | ||
| ], | ||
| "processors": [ | ||
| { | ||
| "json": { | ||
| "field": "message", | ||
| "target_field": "elasticsearch.slowlog" | ||
| } | ||
| }, | ||
| { | ||
| "drop": { | ||
| "if": "ctx.elasticsearch.slowlog.type != 'index_indexing_slowlog' && ctx.elasticsearch.slowlog.type != 'index_search_slowlog'" | ||
| } | ||
| }, | ||
| { | ||
| "remove": { | ||
| "field": "elasticsearch.slowlog.type" | ||
| } | ||
| }, | ||
| { | ||
| "rename": { | ||
| "field": "elasticsearch.slowlog.level", | ||
| "target_field": "log.level" | ||
| } | ||
| }, | ||
| { | ||
| "rename": { | ||
| "field": "elasticsearch.slowlog.component", | ||
| "target_field": "elasticsearch.component" | ||
| } | ||
| }, | ||
| { | ||
| "dot_expander": { | ||
|
||
| "field": "cluster.name", | ||
| "path": "elasticsearch.slowlog" | ||
| } | ||
| }, | ||
| { | ||
| "rename": { | ||
| "field": "elasticsearch.slowlog.cluster.name", | ||
| "target_field": "elasticsearch.cluster.name" | ||
| } | ||
| }, | ||
| { | ||
| "dot_expander": { | ||
| "field": "node.name", | ||
| "path": "elasticsearch.slowlog" | ||
| } | ||
| }, | ||
| { | ||
| "rename": { | ||
| "field": "elasticsearch.slowlog.node.name", | ||
| "target_field": "elasticsearch.node.name" | ||
| } | ||
| }, | ||
| { | ||
| "dot_expander": { | ||
| "field": "cluster.uuid", | ||
| "path": "elasticsearch.slowlog" | ||
| } | ||
| }, | ||
| { | ||
| "rename": { | ||
| "field": "elasticsearch.slowlog.cluster.uuid", | ||
| "target_field": "elasticsearch.cluster.uuid", | ||
| "ignore_missing": true | ||
| } | ||
| }, | ||
| { | ||
| "dot_expander": { | ||
| "field": "node.id", | ||
| "path": "elasticsearch.slowlog" | ||
| } | ||
| }, | ||
| { | ||
| "rename": { | ||
| "field": "elasticsearch.slowlog.node.id", | ||
| "target_field": "elasticsearch.node.id", | ||
| "ignore_missing": true | ||
| } | ||
| }, | ||
| { | ||
| "grok": { | ||
| "field": "elasticsearch.slowlog.message", | ||
| "pattern_definitions" : { | ||
| "GREEDYMULTILINE" : "(.|\n)*", | ||
| "INDEXNAME": "[a-zA-Z0-9_.-]*" | ||
| }, | ||
| "patterns": [ | ||
| "(\\[%{INDEXNAME:elasticsearch.index.name}\\]\\[%{NUMBER:elasticsearch.shard.id}\\])?(%{SPACE})?(\\[%{INDEXNAME:elasticsearch.index.name}\\/%{DATA:elasticsearch.index.id}\\])?(%{SPACE})?%{SPACE}(took\\[%{DATA:elasticsearch.slowlog.took}\\],)?%{SPACE}(took_millis\\[%{NUMBER:elasticsearch.slowlog.duration:long}\\],)?%{SPACE}(type\\[%{DATA:elasticsearch.slowlog.type}\\],)?%{SPACE}(id\\[%{DATA:elasticsearch.slowlog.id}\\],)?%{SPACE}(routing\\[%{DATA:elasticsearch.slowlog.routing}\\],)?%{SPACE}(total_hits\\[%{NUMBER:elasticsearch.slowlog.total_hits:int}\\],)?%{SPACE}(types\\[%{DATA:elasticsearch.slowlog.types}\\],)?%{SPACE}(stats\\[%{DATA:elasticsearch.slowlog.stats}\\],)?%{SPACE}(search_type\\[%{DATA:elasticsearch.slowlog.search_type}\\],)?%{SPACE}(total_shards\\[%{NUMBER:elasticsearch.slowlog.total_shards:int}\\],)?%{SPACE}(source\\[%{GREEDYMULTILINE:elasticsearch.slowlog.source_query}\\])?,?%{SPACE}(extra_source\\[%{DATA:elasticsearch.slowlog.extra_source}\\])?,?" | ||
| ] | ||
| } | ||
| }, | ||
| { | ||
| "remove": { | ||
| "field": "elasticsearch.slowlog.message" | ||
| } | ||
| } | ||
| ] | ||
| } | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,33 @@ | ||
| { | ||
| "description": "Pipeline for parsing elasticsearch slow logs in plaintext format.", | ||
| "processors": [ | ||
| { | ||
| "grok": { | ||
| "field": "message", | ||
| "pattern_definitions": { | ||
| "GREEDYMULTILINE": "(.|\n)*", | ||
| "INDEXNAME": "[a-zA-Z0-9_.-]*" | ||
| }, | ||
| "patterns": [ | ||
| "\\[%{TIMESTAMP_ISO8601:elasticsearch.slowlog.timestamp}\\]\\[%{WORD:log.level}(%{SPACE})?\\]\\[%{DATA:elasticsearch.slowlog.logger}\\]%{SPACE}\\[%{WORD:elasticsearch.node.name}\\](%{SPACE})?(\\[%{INDEXNAME:elasticsearch.index.name}\\]\\[%{NUMBER:elasticsearch.shard.id}\\])?(%{SPACE})?(\\[%{INDEXNAME:elasticsearch.index.name}\\/%{DATA:elasticsearch.index.id}\\])?(%{SPACE})?%{SPACE}(took\\[%{DATA:elasticsearch.slowlog.took}\\],)?%{SPACE}(took_millis\\[%{NUMBER:elasticsearch.slowlog.duration:long}\\],)?%{SPACE}(type\\[%{DATA:elasticsearch.slowlog.type}\\],)?%{SPACE}(id\\[%{DATA:elasticsearch.slowlog.id}\\],)?%{SPACE}(routing\\[%{DATA:elasticsearch.slowlog.routing}\\],)?%{SPACE}(total_hits\\[%{NUMBER:elasticsearch.slowlog.total_hits:int}\\],)?%{SPACE}(types\\[%{DATA:elasticsearch.slowlog.types}\\],)?%{SPACE}(stats\\[%{DATA:elasticsearch.slowlog.stats}\\],)?%{SPACE}(search_type\\[%{DATA:elasticsearch.slowlog.search_type}\\],)?%{SPACE}(total_shards\\[%{NUMBER:elasticsearch.slowlog.total_shards:int}\\],)?%{SPACE}(source\\[%{GREEDYMULTILINE:elasticsearch.slowlog.source_query}\\])?,?%{SPACE}(extra_source\\[%{DATA:elasticsearch.slowlog.extra_source}\\])?,?" | ||
| ] | ||
| } | ||
| }, | ||
| { | ||
| "split": { | ||
| "if": "ctx.elasticsearch.slowlog?.stats != ''", | ||
| "field": "elasticsearch.slowlog.stats", | ||
| "separator": ",", | ||
| "ignore_missing": true | ||
| } | ||
| } | ||
| ], | ||
| "on_failure": [ | ||
| { | ||
| "set": { | ||
| "field": "error.message", | ||
| "value": "{{ _ingest.on_failure_message }}" | ||
| } | ||
| } | ||
| ] | ||
| } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,70 +1,81 @@ | ||
| { | ||
| "description": "Pipeline for parsing elasticsearch slowlog logs", | ||
| "processors": [ | ||
| { | ||
| "rename": { | ||
| "field": "@timestamp", | ||
| "target_field": "event.created" | ||
| } | ||
| }, | ||
| { | ||
| "grok": { | ||
| "field": "message", | ||
| "pattern_definitions" : { | ||
| "GREEDYMULTILINE" : "(.|\n)*", | ||
| "INDEXNAME": "[a-zA-Z0-9_.-]*" | ||
| }, | ||
| "patterns": [ | ||
| "\\[%{TIMESTAMP_ISO8601:elasticsearch.slowlog.timestamp}\\]\\[%{WORD:log.level}(%{SPACE})?\\]\\[%{DATA:elasticsearch.slowlog.logger}\\]%{SPACE}\\[%{WORD:elasticsearch.node.name}\\](%{SPACE})?(\\[%{INDEXNAME:elasticsearch.index.name}\\]\\[%{NUMBER:elasticsearch.shard.id}\\])?(%{SPACE})?(\\[%{INDEXNAME:elasticsearch.index.name}\\/%{DATA:elasticsearch.index.id}\\])?(%{SPACE})?%{SPACE}(took\\[%{DATA:elasticsearch.slowlog.took}\\],)?%{SPACE}(took_millis\\[%{NUMBER:temp.duration:long}\\],)?%{SPACE}(type\\[%{DATA:elasticsearch.slowlog.type}\\],)?%{SPACE}(id\\[%{DATA:elasticsearch.slowlog.id}\\],)?%{SPACE}(routing\\[%{DATA:elasticsearch.slowlog.routing}\\],)?%{SPACE}(total_hits\\[%{NUMBER:elasticsearch.slowlog.total_hits:int}\\],)?%{SPACE}(types\\[%{DATA:elasticsearch.slowlog.types}\\],)?%{SPACE}(stats\\[%{DATA:elasticsearch.slowlog.stats}\\],)?%{SPACE}(search_type\\[%{DATA:elasticsearch.slowlog.search_type}\\],)?%{SPACE}(total_shards\\[%{NUMBER:elasticsearch.slowlog.total_shards:int}\\],)?%{SPACE}(source\\[%{GREEDYMULTILINE:elasticsearch.slowlog.source_query}\\])?,?%{SPACE}(extra_source\\[%{DATA:elasticsearch.slowlog.extra_source}\\])?,?" | ||
| ] | ||
| } | ||
| }, | ||
| { | ||
| "split": { | ||
| "if": "ctx.elasticsearch.slowlog?.stats != ''", | ||
| "field": "elasticsearch.slowlog.stats", | ||
| "separator": ",", | ||
| "ignore_missing": true | ||
| } | ||
| }, | ||
| { | ||
| "date": { | ||
| "field": "elasticsearch.slowlog.timestamp", | ||
| "target_field": "@timestamp", | ||
| "formats": [ | ||
| "ISO8601" | ||
| ], | ||
| {< if .convert_timezone >}"timezone": "{{ event.timezone }}",{< end >} | ||
| "ignore_failure": true | ||
| } | ||
| }, | ||
| { | ||
| "remove": { | ||
| "field": [ | ||
| "elasticsearch.slowlog.timestamp" | ||
| ] | ||
| } | ||
| }, | ||
|
|
||
| { | ||
| "script": { | ||
| "lang": "painless", | ||
| "source": "ctx.event.duration = Math.round(ctx.temp.duration * params.scale)", | ||
| "params": { "scale": 1000000 }, | ||
| "if": "ctx.temp?.duration != null" | ||
| } | ||
| }, | ||
| { | ||
| "remove": { | ||
| "field": "temp.duration", | ||
| "ignore_missing": true | ||
| } | ||
| } | ||
| ], | ||
| "on_failure" : [{ | ||
| "set" : { | ||
| "field" : "error.message", | ||
| "value" : "{{ _ingest.on_failure_message }}" | ||
| } | ||
| }] | ||
| "description": "Pipeline for parsing elasticsearch slow logs.", | ||
| "processors": [ | ||
| { | ||
| "rename": { | ||
| "field": "@timestamp", | ||
| "target_field": "event.created" | ||
| } | ||
| }, | ||
| { | ||
| "grok": { | ||
| "field": "message", | ||
| "patterns": [ | ||
| "^%{CHAR:first_char}" | ||
| ], | ||
| "pattern_definitions": { | ||
| "CHAR": "." | ||
| } | ||
| } | ||
| }, | ||
| { | ||
| "pipeline": { | ||
| "if": "ctx.first_char != '{'", | ||
| "name": "{< IngestPipeline "pipeline-plaintext" >}" | ||
| } | ||
| }, | ||
| { | ||
| "pipeline": { | ||
| "if": "ctx.first_char == '{'", | ||
| "name": "{< IngestPipeline "pipeline-json" >}" | ||
| } | ||
| }, | ||
| { | ||
| "date": { | ||
| "field": "elasticsearch.slowlog.timestamp", | ||
| "target_field": "@timestamp", | ||
| "formats": [ | ||
| "ISO8601" | ||
| ], | ||
| {< if .convert_timezone >}"timezone": "{{ event.timezone }}",{< end >} | ||
| "ignore_failure": true | ||
| } | ||
| }, | ||
| { | ||
| "remove": { | ||
| "field": "elasticsearch.slowlog.timestamp" | ||
| } | ||
| }, | ||
| { | ||
| "script": { | ||
| "lang": "painless", | ||
| "source": "ctx.event.duration = Math.round(ctx.elasticsearch.slowlog.duration * params.scale)", | ||
| "params": { | ||
| "scale": 1000000 | ||
| }, | ||
| "if": "ctx.elasticsearch.slowlog?.duration != null" | ||
| } | ||
| }, | ||
| { | ||
| "remove": { | ||
| "field": "elasticsearch.slowlog.duration", | ||
| "ignore_missing": true | ||
| } | ||
| }, | ||
| { | ||
| "remove": { | ||
| "field": [ | ||
| "first_char" | ||
| ] | ||
| } | ||
| } | ||
| ], | ||
| "on_failure": [ | ||
| { | ||
| "set": { | ||
| "field": "error.message", | ||
| "value": "{{ _ingest.on_failure_message }}" | ||
| } | ||
| } | ||
| ] | ||
| } |
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 kind of interesting. In the event for json it's not a multiline anymore but here we still need the multiline config 🤔
Good for now, jus thought I mention it.