Skip to content

Commit

Permalink
Make error fields optional in partition event (elastic#3089) (elastic…
Browse files Browse the repository at this point in the history
…#3092)

* Update data.json
(cherry picked from commit 298416e)
  • Loading branch information
ruflin authored and tsg committed Dec 1, 2016
1 parent 94a6f83 commit 391f3e7
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 15 deletions.
3 changes: 1 addition & 2 deletions metricbeat/module/kafka/partition/_meta/data.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,14 +15,13 @@
"oldest": 0
},
"partition": {
"error": 0,
"id": 0,
"insync_replica": true,
"leader": 0,
"replica": 0
},
"topic": {
"name": "test-metricbeat-8760238589576171408"
"name": "test-metricbeat-70692474374989458"
}
}
},
Expand Down
34 changes: 21 additions & 13 deletions metricbeat/module/kafka/partition/partition.go
Original file line number Diff line number Diff line change
Expand Up @@ -130,9 +130,12 @@ func (m *MetricSet) Fetch() ([]common.MapStr, error) {
for _, topic := range response.Topics {
evtTopic := common.MapStr{
"name": topic.Name,
"error": common.MapStr{
}

if topic.Err != 0 {
evtTopic["error"] = common.MapStr{
"code": topic.Err,
},
}
}

for _, partition := range topic.Partitions {
Expand All @@ -157,19 +160,24 @@ func (m *MetricSet) Fetch() ([]common.MapStr, error) {
continue
}

partitionEvent := common.MapStr{
"id": partition.ID,
"leader": partition.Leader,
"replica": id,
"insync_replica": hasID(id, partition.Isr),
}

if partition.Err != 0 {
partitionEvent["error"] = common.MapStr{
"code": partition.Err,
}
}

// create event
event := common.MapStr{
"topic": evtTopic,
"broker": evtBroker,
"partition": common.MapStr{
"id": partition.ID,
"error": common.MapStr{
"code": partition.Err,
},
"leader": partition.Leader,
"replica": id,
"insync_replica": hasID(id, partition.Isr),
},
"topic": evtTopic,
"broker": evtBroker,
"partition": partitionEvent,
"offset": common.MapStr{
"newest": offNewest,
"oldest": offOldest,
Expand Down

0 comments on commit 391f3e7

Please sign in to comment.