Skip to content

Commit

Permalink
Include broker ID with its status and update README
Browse files Browse the repository at this point in the history
  • Loading branch information
nichegriffy authored and andreas-schroeder committed Aug 29, 2018
1 parent b931bf9 commit 0307c1f
Show file tree
Hide file tree
Showing 3 changed files with 47 additions and 14 deletions.
58 changes: 45 additions & 13 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -45,11 +45,11 @@ information provided by kafka-health-check.
## Usage

```
kafka-health-check usage:
Usage of kafka-health-check:
-broker-host string
ip address or hostname of broker host
ip address or hostname of broker host (default "localhost")
-broker-id uint
id of the Kafka broker to health check (default 0)
id of the Kafka broker to health check
-broker-port uint
Kafka broker port (default 9092)
-check-interval duration
Expand All @@ -74,7 +74,10 @@ Broker health can be queried at `/`:

```
$ curl -s <broker-host>:8000/
{"status":"sync"}
{
"broker": 1,
"status": "sync"
}
```

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

```
$ curl -s <broker-host>:8000/
{"status":"imok","out-of-sync":[{"topic":"mytopic","partition":0}],"replication-failures":1}
{
"broker": 3,
"status": "imok",
"out-of-sync": [
{
"topic": "mytopic",
"partition": 0
}
],
"replication-failures": 1
}
```

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

```
$ curl -s <broker-host>:8000/cluster
{"status":"green"}
{
"status": "green"
}
```

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

```
$ curl -s <broker-host>:8000/cluster
{"status":"yellow","topics":[
{"topic":"mytopic","Status":"yellow","partitions":{
"2":{"status":"yellow","OSR":[3]},
"1":{"status":"yellow","OSR":[3]}
}}
]}
{
"status": "yellow",
"topics": [
{
"topic": "mytopic",
"status": "yellow",
"partitions": {
"1": {
"status": "yellow",
"OSR": [
3
]
},
"2": {
"status": "yellow",
"OSR": [
3
]
}
}
}
]
}
```

The fields for additional info and structures are:
* `topics` for topic replication status: `[{"topic":"mytopic","Status":"yellow","partitions":{"2":{"status":"yellow","OSR":[3]}}}]`
* `topics` for topic replication status: `[{"topic":"mytopic","status":"yellow","partitions":{"2":{"status":"yellow","OSR":[3]}}}]`
In this data, `OSR` means out-of-sync replica and contains the list of all brokers that are not in the ISR.
* `metadata` for inconsistencies between ZooKeeper and Kafka metadata: `[{"broker":3,"status":"red","problem":"Missing in ZooKeeper"}]`
* `zookeeper` for problems with ZooKeeper connection or data, contains a single string: `"Fetching brokers failed: ..."`
Expand Down
2 changes: 1 addition & 1 deletion check/broker_health_check.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ func (check *HealthCheck) checkBrokerHealth(metadata *proto.MetadataResp) Broker
status = check.waitForMessage(message)
}

brokerStatus := BrokerStatus{Status: status}
brokerStatus := BrokerStatus{ID: int32(check.config.brokerID), Status: status}
if status == healthy {
check.producer.Produce(check.config.replicationTopicName, check.replicationPartitionID, message)
check.brokerInSync(&brokerStatus, metadata)
Expand Down
1 change: 1 addition & 0 deletions check/status.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ type StatusReport interface {
}

type BrokerStatus struct {
ID int32 `json:"broker"`
Status string `json:"status"`
OutOfSync []ReplicationStatus `json:"out-of-sync,omitempty"`
ReplicationFailures uint `json:"replication-failures,omitempty"`
Expand Down

0 comments on commit 0307c1f

Please sign in to comment.