etcdctl endpoint health -w json
does not output in JSON #9532
Closed
Description
The health subcommands of etcdctl do not output in JSON even when JSON is explicitly requested:
$ ETCDCTL_API=3 etcdctl endpoint health -w json
http://127.0.0.1:10001 is healthy: successfully committed proposal: took = 668.335µs
$ ETCDCTL_API=3 etcdctl endpoint --cluster health -w json
http://127.0.0.1:20001 is healthy: successfully committed proposal: took = 601.324µs
http://127.0.0.1:20003 is healthy: successfully committed proposal: took = 804.816µs
http://127.0.0.1:20002 is unhealthy: failed to connect: dial tcp 127.0.0.1:20002: connect: connection refused
Error: unhealthy cluster
Something like this would work:
{
"cluster": {
"health": {
"healthy": "false"
},
"peers": [
{
"Endpoint": "http://127.0.0.1:20003",
"health": {
"healthy": "true",
"reason": "successfully committed proposal: took = 804.816µs"
}
},
{
"Endpoint": "http://127.0.0.1:20001",
"health": {
"healthy": "true",
"reason": "successfully committed proposal: took = 601.324µs"
}
},
{
"Endpoint": "http://127.0.0.1:20002",
"health": {
"healthy": "false",
"reason": "failed to connect: dial tcp 127.0.0.1:20002: connect: connection refused"
}
}
]
}
}