Skip to content

Commit 0307c1f

Browse files
nichegriffyandreas-schroeder
authored andcommitted
Include broker ID with its status and update README
1 parent b931bf9 commit 0307c1f

File tree

3 files changed

+47
-14
lines changed

3 files changed

+47
-14
lines changed

README.md

Lines changed: 45 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -45,11 +45,11 @@ information provided by kafka-health-check.
4545
## Usage
4646

4747
```
48-
kafka-health-check usage:
48+
Usage of kafka-health-check:
4949
-broker-host string
50-
ip address or hostname of broker host
50+
ip address or hostname of broker host (default "localhost")
5151
-broker-id uint
52-
id of the Kafka broker to health check (default 0)
52+
id of the Kafka broker to health check
5353
-broker-port uint
5454
Kafka broker port (default 9092)
5555
-check-interval duration
@@ -74,7 +74,10 @@ Broker health can be queried at `/`:
7474

7575
```
7676
$ curl -s <broker-host>:8000/
77-
{"status":"sync"}
77+
{
78+
"broker": 1,
79+
"status": "sync"
80+
}
7881
```
7982

8083
Return codes and status values are:
@@ -90,7 +93,17 @@ The returned json contains details about replicas the broker is lagging behind:
9093

9194
```
9295
$ curl -s <broker-host>:8000/
93-
{"status":"imok","out-of-sync":[{"topic":"mytopic","partition":0}],"replication-failures":1}
96+
{
97+
"broker": 3,
98+
"status": "imok",
99+
"out-of-sync": [
100+
{
101+
"topic": "mytopic",
102+
"partition": 0
103+
}
104+
],
105+
"replication-failures": 1
106+
}
94107
```
95108

96109
## Cluster Health
@@ -99,7 +112,9 @@ Cluster health can be queried at `/cluster`:
99112

100113
```
101114
$ curl -s <broker-host>:8000/cluster
102-
{"status":"green"}
115+
{
116+
"status": "green"
117+
}
103118
```
104119

105120
Return codes and status values are:
@@ -111,16 +126,33 @@ The returned json contains details about metadata status and partition replicati
111126

112127
```
113128
$ curl -s <broker-host>:8000/cluster
114-
{"status":"yellow","topics":[
115-
{"topic":"mytopic","Status":"yellow","partitions":{
116-
"2":{"status":"yellow","OSR":[3]},
117-
"1":{"status":"yellow","OSR":[3]}
118-
}}
119-
]}
129+
{
130+
"status": "yellow",
131+
"topics": [
132+
{
133+
"topic": "mytopic",
134+
"status": "yellow",
135+
"partitions": {
136+
"1": {
137+
"status": "yellow",
138+
"OSR": [
139+
3
140+
]
141+
},
142+
"2": {
143+
"status": "yellow",
144+
"OSR": [
145+
3
146+
]
147+
}
148+
}
149+
}
150+
]
151+
}
120152
```
121153

122154
The fields for additional info and structures are:
123-
* `topics` for topic replication status: `[{"topic":"mytopic","Status":"yellow","partitions":{"2":{"status":"yellow","OSR":[3]}}}]`
155+
* `topics` for topic replication status: `[{"topic":"mytopic","status":"yellow","partitions":{"2":{"status":"yellow","OSR":[3]}}}]`
124156
In this data, `OSR` means out-of-sync replica and contains the list of all brokers that are not in the ISR.
125157
* `metadata` for inconsistencies between ZooKeeper and Kafka metadata: `[{"broker":3,"status":"red","problem":"Missing in ZooKeeper"}]`
126158
* `zookeeper` for problems with ZooKeeper connection or data, contains a single string: `"Fetching brokers failed: ..."`

check/broker_health_check.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ func (check *HealthCheck) checkBrokerHealth(metadata *proto.MetadataResp) Broker
2121
status = check.waitForMessage(message)
2222
}
2323

24-
brokerStatus := BrokerStatus{Status: status}
24+
brokerStatus := BrokerStatus{ID: int32(check.config.brokerID), Status: status}
2525
if status == healthy {
2626
check.producer.Produce(check.config.replicationTopicName, check.replicationPartitionID, message)
2727
check.brokerInSync(&brokerStatus, metadata)

check/status.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ type StatusReport interface {
2121
}
2222

2323
type BrokerStatus struct {
24+
ID int32 `json:"broker"`
2425
Status string `json:"status"`
2526
OutOfSync []ReplicationStatus `json:"out-of-sync,omitempty"`
2627
ReplicationFailures uint `json:"replication-failures,omitempty"`

0 commit comments

Comments
 (0)