Skip to content

Teach elasticsearch/slowlog fileset to parse more fields #11939

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
merged 8 commits into from
Jul 15, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.next.asciidoc
Original file line number Diff line number Diff line change
Expand Up @@ -231,6 +231,7 @@ https://github.com/elastic/beats/compare/v7.0.0-alpha2...master[Check the HEAD d
- Add module for ingesting Cisco IOS logs over syslog. {pull}12748[12748]
- Add module for ingesting Google Cloud VPC flow logs. {pull}12747[12747]
- Add netflow dashboards based on Logstash netflow. {pull}12857[12857]
- Parse more fields from Elasticsearch slowlogs. {pull}11939[11939]

*Heartbeat*

Expand Down
9 changes: 9 additions & 0 deletions filebeat/docs/fields.asciidoc
Original file line number Diff line number Diff line change
Expand Up @@ -5441,6 +5441,15 @@ example: doc

--

*`elasticsearch.slowlog.source`*::
+
--
Source of document that was indexed

type: keyword

--

[[exported-fields-envoyproxy]]
== Envoyproxy fields

Expand Down
2 changes: 1 addition & 1 deletion filebeat/module/elasticsearch/fields.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 3 additions & 0 deletions filebeat/module/elasticsearch/slowlog/_meta/fields.yml
Original file line number Diff line number Diff line change
Expand Up @@ -51,3 +51,6 @@
description: "Type"
example: "doc"
type: keyword
- name: source
description: Source of document that was indexed
type: keyword
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,27 @@
"ignore_missing": true
}
},
{
"rename": {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

is this going to work if we remove that field in 8? (I have remove that so possibly there this probably will be empty/missing). I forgot about that in my PR, fixing now

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, it should be okay because of the ignore_missing flag set on this processor (see a couple lines below). In 9 we can completely remove this processor from the pipeline as, by then we won't expect to see any log lines with doc_type in them.

"field": "elasticsearch.slowlog.doc_type",
"target_field": "elasticsearch.slowlog.types",
"ignore_missing": true
}
},
{
"convert": {
"field": "elasticsearch.slowlog.took_millis",
"type": "float",
"ignore_missing": true
}
},
{
"rename": {
"field": "elasticsearch.slowlog.took_millis",
"target_field": "elasticsearch.slowlog.duration",
"ignore_missing": true
}
},
{
"grok": {
"field": "elasticsearch.slowlog.message",
Expand All @@ -95,7 +116,8 @@
"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}\\])?,?"
"(\\[%{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}\\])?,?",
"\\[%{INDEXNAME:elasticsearch.index.name}\\]\\[%{NUMBER:elasticsearch.shard.id}\\]"
]
}
},
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
{"type": "index_indexing_slowlog", "timestamp": "2019-06-24T15:01:11,415-04:00", "level": "WARN", "component": "i.i.s.index", "cluster.name": "esprod", "node.name": "esprod0", "message": "[foo/6cpavWDYRO6pyxezB0LepA]", "took": "3ms", "took_millis": "3", "doc_type": "t", "id": "1", "routing": "", "source": "{\"foo\":\"bar\"}", "cluster.uuid": "b28RGuVmRDimbAkNTVbacg", "node.id": "erxPlzmKQOGUdrDxGrww_g" }
{"type": "index_indexing_slowlog", "timestamp": "2019-07-09T04:48:28,203-04:00", "level": "WARN", "component": "i.i.s.index", "cluster.name": "es1", "node.name": "es1_1", "message": "[foo/DubP3paOQJCtD1EkUmqxpw]", "took": "2.3ms", "took_millis": "2", "doc_type": "_doc", "id": "1", "source": "{\"foo\":\"bar\"}", "cluster.uuid": "xOp8Gs9TTa-SoSWcs6NZHg", "node.id": "BgSzU7SUTgeRYqzbiyf1sA" }
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
[
{
"@timestamp": "2019-06-24T19:01:11.415Z",
"elasticsearch.cluster.name": "esprod",
"elasticsearch.cluster.uuid": "b28RGuVmRDimbAkNTVbacg",
"elasticsearch.component": "i.i.s.index",
"elasticsearch.index.id": "6cpavWDYRO6pyxezB0LepA",
"elasticsearch.index.name": "foo",
"elasticsearch.node.id": "erxPlzmKQOGUdrDxGrww_g",
"elasticsearch.node.name": "esprod0",
"elasticsearch.slowlog.id": "1",
"elasticsearch.slowlog.routing": "",
"elasticsearch.slowlog.source": "{\"foo\":\"bar\"}",
"elasticsearch.slowlog.took": "3ms",
"elasticsearch.slowlog.types": "t",
"event.dataset": "elasticsearch.slowlog",
"event.duration": 3000000,
"event.module": "elasticsearch",
"event.timezone": "+00:00",
"fileset.name": "slowlog",
"input.type": "log",
"log.level": "WARN",
"log.offset": 0,
"message": "{\"type\": \"index_indexing_slowlog\", \"timestamp\": \"2019-06-24T15:01:11,415-04:00\", \"level\": \"WARN\", \"component\": \"i.i.s.index\", \"cluster.name\": \"esprod\", \"node.name\": \"esprod0\", \"message\": \"[foo/6cpavWDYRO6pyxezB0LepA]\", \"took\": \"3ms\", \"took_millis\": \"3\", \"doc_type\": \"t\", \"id\": \"1\", \"routing\": \"\", \"source\": \"{\\\"foo\\\":\\\"bar\\\"}\", \"cluster.uuid\": \"b28RGuVmRDimbAkNTVbacg\", \"node.id\": \"erxPlzmKQOGUdrDxGrww_g\" }",
"service.type": "elasticsearch"
},
{
"@timestamp": "2019-07-09T08:48:28.203Z",
"elasticsearch.cluster.name": "es1",
"elasticsearch.cluster.uuid": "xOp8Gs9TTa-SoSWcs6NZHg",
"elasticsearch.component": "i.i.s.index",
"elasticsearch.index.id": "DubP3paOQJCtD1EkUmqxpw",
"elasticsearch.index.name": "foo",
"elasticsearch.node.id": "BgSzU7SUTgeRYqzbiyf1sA",
"elasticsearch.node.name": "es1_1",
"elasticsearch.slowlog.id": "1",
"elasticsearch.slowlog.source": "{\"foo\":\"bar\"}",
"elasticsearch.slowlog.took": "2.3ms",
"elasticsearch.slowlog.types": "_doc",
"event.dataset": "elasticsearch.slowlog",
"event.duration": 2000000,
"event.module": "elasticsearch",
"event.timezone": "+00:00",
"fileset.name": "slowlog",
"input.type": "log",
"log.level": "WARN",
"log.offset": 409,
"message": "{\"type\": \"index_indexing_slowlog\", \"timestamp\": \"2019-07-09T04:48:28,203-04:00\", \"level\": \"WARN\", \"component\": \"i.i.s.index\", \"cluster.name\": \"es1\", \"node.name\": \"es1_1\", \"message\": \"[foo/DubP3paOQJCtD1EkUmqxpw]\", \"took\": \"2.3ms\", \"took_millis\": \"2\", \"doc_type\": \"_doc\", \"id\": \"1\", \"source\": \"{\\\"foo\\\":\\\"bar\\\"}\", \"cluster.uuid\": \"xOp8Gs9TTa-SoSWcs6NZHg\", \"node.id\": \"BgSzU7SUTgeRYqzbiyf1sA\" }",
"service.type": "elasticsearch"
}
]
Loading