Skip to content
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

Cherry-pick #8504 to 6.x: Add kafka fields needed for dashboards #8644

Merged
merged 3 commits into from
Oct 18, 2018
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.asciidoc
Original file line number Diff line number Diff line change
Expand Up @@ -135,6 +135,7 @@ https://github.com/elastic/beats/compare/v6.4.0...6.x[Check the HEAD diff]
- Support for Kafka 2.0.0 {pull}8399[8399]
- Added support for query params in configuration {issue}8286[8286] {pull}8292[8292]
- Add container image for docker metricsets. {issue}8214[8214] {pull}8438[8438]
- Precalculate composed id fields for kafka dashboards. {pull}8504[8504]
- Add support for `full` status page output for php-fpm module as a separate metricset called `process`. {pull}8394[8394]

*Packetbeat*
Expand Down
18 changes: 18 additions & 0 deletions metricbeat/docs/fields.asciidoc
Original file line number Diff line number Diff line change
Expand Up @@ -7108,6 +7108,24 @@ type: long
Partition id.


--

*`kafka.partition.topic_id`*::
+
--
type: keyword

Unique id of the partition in the topic.

--

*`kafka.partition.topic_broker_id`*::
+
--
type: keyword

Unique id of the partition in the topic and the broker.

--

[float]
Expand Down
10 changes: 10 additions & 0 deletions metricbeat/module/kafka/_meta/fields.yml
Original file line number Diff line number Diff line change
Expand Up @@ -39,3 +39,13 @@
type: long
description: >
Partition id.

- name: partition.topic_id
type: keyword
description:
Unique id of the partition in the topic.

- name: partition.topic_broker_id
type: keyword
description:
Unique id of the partition in the topic and the broker.
7 changes: 4 additions & 3 deletions metricbeat/module/kafka/consumergroup/_meta/data.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
"client": {
"host": "172.18.0.1",
"id": "sarama",
"member_id": "sarama-714cfb8b-39e5-4128-9109-e5056c5e8f56"
"member_id": "sarama-fcb5a5db-0474-4f3a-a5af-29e2f14549c5"
},
"error": {
"code": 0
Expand All @@ -29,7 +29,8 @@
"topic": "metricbeat-test"
},
"partition": {
"id": 0
"id": 0,
"topic_id": "0-metricbeat-test"
},
"topic": {
"name": "metricbeat-test"
Expand All @@ -41,4 +42,4 @@
"name": "consumergroup",
"rtt": 115
}
}
}
7 changes: 6 additions & 1 deletion metricbeat/module/kafka/consumergroup/consumergroup.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ package consumergroup

import (
"crypto/tls"
"fmt"

"github.com/pkg/errors"

Expand Down Expand Up @@ -111,6 +112,9 @@ func (m *MetricSet) Fetch(r mb.ReporterV2) {
}

emitEvent := func(event common.MapStr) {
// Helpful IDs to avoid scripts on queries
partitionTopicID := fmt.Sprintf("%d-%s", event["partition"], event["topic"])

// TODO (deprecation): Remove fields from MetricSetFields moved to ModuleFields
event["broker"] = brokerInfo
r.Event(mb.Event{
Expand All @@ -120,7 +124,8 @@ func (m *MetricSet) Fetch(r mb.ReporterV2) {
"name": event["topic"],
},
"partition": common.MapStr{
"id": event["partition"],
"id": event["partition"],
"topic_id": partitionTopicID,
},
},
MetricSetFields: event,
Expand Down
2 changes: 1 addition & 1 deletion metricbeat/module/kafka/fields.go

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

9 changes: 6 additions & 3 deletions metricbeat/module/kafka/partition/_meta/data.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
"address": "172.18.0.2:9092",
"id": 0
},
"id": 0,
"offset": {
"newest": 0,
"oldest": 0
Expand All @@ -26,11 +27,13 @@
"replica": 0
},
"topic": {
"name": "foo-1532945633-185372965"
}
"name": "foo-1538389014-739473801"
},
"topic_broker_id": "0-foo-1538389014-739473801-0",
"topic_id": "0-foo-1538389014-739473801"
},
"topic": {
"name": "foo-1532945633-185372965"
"name": "foo-1538389014-739473801"
}
},
"metricset": {
Expand Down
13 changes: 10 additions & 3 deletions metricbeat/module/kafka/partition/partition.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ package partition
import (
"crypto/tls"
"errors"
"fmt"

"github.com/elastic/beats/libbeat/common"
"github.com/elastic/beats/libbeat/common/cfgwarn"
Expand Down Expand Up @@ -167,8 +168,17 @@ func (m *MetricSet) Fetch(r mb.ReporterV2) {
}
}

// Helpful IDs to avoid scripts on queries
partitionTopicID := fmt.Sprintf("%d-%s", partition.ID, topic.Name)
partitionTopicBrokerID := fmt.Sprintf("%s-%d", partitionTopicID, id)

// create event
event := common.MapStr{
// Common `kafka.partition` fields
"id": partition.ID,
"topic_id": partitionTopicID,
"topic_broker_id": partitionTopicBrokerID,

"topic": evtTopic,
"broker": evtBroker,
"partition": partitionEvent,
Expand All @@ -183,9 +193,6 @@ func (m *MetricSet) Fetch(r mb.ReporterV2) {
ModuleFields: common.MapStr{
"broker": evtBroker,
"topic": evtTopic,
"partition": common.MapStr{
"id": partition.ID,
},
},
MetricSetFields: event,
})
Expand Down