how to do you call the kafka manager api to get topic summary
I have been trying to call the api and get a summary for a topic but i get it in the form of HTML file instead of a json or anything. Is there anyway I can call the api to get like offsets
Here are the API routes:
GET /api/status/:c/brokers controllers.api.KafkaStateCheck.brokers(c:String) GET /api/status/:c/topics controllers.api.KafkaStateCheck.topics(c:String) GET /api/status/:c/topicIdentities controllers.api.KafkaStateCheck.topicIdentities(c:String) GET /api/status/clusters controllers.api.KafkaStateCheck.clusters GET /api/status/:c/:t/underReplicatedPartitions controllers.api.KafkaStateCheck.underReplicatedPartitions(c:String,t:String) GET /api/status/:c/:t/unavailablePartitions controllers.api.KafkaStateCheck.unavailablePartitions(c:String,t:String) GET /api/status/:cluster/:consumer/:topic/topicSummary controllers.api.KafkaStateCheck.topicSummaryAction(cluster:String, consumer:String, topic:String, consumerType:String) GET /api/status/:cluster/:consumer/groupSummary controllers.api.KafkaStateCheck.groupSummaryAction(cluster:String, consumer:String, consumerType:String) GET /api/status/:cluster/consumersSummary controllers.api.KafkaStateCheck.consumersSummaryAction(cluster:String)
So i hit the endpoint but i get like a html page back. Is there any where i can get it in like json format with no html tags and all
Show me what you are doing. Provide some debug information. Maybe try it with curl and show me the results.
self write Controller:
def getTopicDetail(clustername:String, topic:String) = Action.async { request =>
val futureErrorOrTopicIdentity = kafkaManager.getTopicIdentity(clustername, topic)
val futureErrorOrConsumerList = kafkaManager.getConsumersForTopic(clustername, topic)
futureErrorOrTopicIdentity.zip(futureErrorOrConsumerList).map {
case (errorOrTopicIdentity, errorOrConsumerList) =>
var result:String = ""
var errorMsg:String = ""
var topicInfo:TopicIdentity = null
var consumers:ConsumerListExtended = null
errorOrTopicIdentity match {
case -\/(e) => errorMsg = e.msg
case \/-(t) => topicInfo = t
}
if (errorMsg != "") {
result = "{\"errcode\":\"Failed\",\"errmsg\":\"" + errorMsg + "\"}"
} else {
result = "{\"errcode\":\"OK\",\"errmsg\":\"\", \"result\":{"
result += "\"replications\":" + topicInfo.replicationFactor + ","
result += "\"partitons\":" + topicInfo.partitions + ","
result += "\"sum_offset\":" + topicInfo.summedTopicOffsets + ","
result += "\"brokers\": ["
for (i <- 0 until topicInfo.partitionsByBroker.size) {
if (i != 0) {
result += ","
}
result += "{"
result += "\"id\":" + topicInfo.partitionsByBroker(i).id + ","
result += "\"partitions\":\""
for (j <- 0 until topicInfo.partitionsByBroker(i).partitions.size) {
if (j != 0) {
result += ","
}
result += topicInfo.partitionsByBroker(i).partitions(j)
}
result += "\""
result += "}"
}
result += "],"
var k = 0
result += "\"consumer_groups\":{"
errorOrConsumerList.foreach (consumerList =>
for ((c:String, ct: ConsumerType) <- consumerList) {
if (k != 0) {
result += ","
}
k += 1
result += "\"" + c + "\":" + "\"" + ct + "\""
})
result += "}"
result += "}"
result += "}"
}
Ok(result)
}
}
@patelh : below is the command i am running
curl -H "Content-type: application/json" -H "Accept: application/json" "http://abc.xyz.com:8080/api/status/vv/consumersSummary/sfs/ZK/topicSummary" (i have change the host and other things)
<p id="detail">
For request 'GET /api/status/vv/consumersSummary/sfs/ZK/topicSummary'
</p>
can u give me an example of how to get topic summary and what parameters i need to pass. as I am not able to get it to work
@patelh : i am trying to get topic summary using GET /api/status/:cluster/:consumer/:topic/topicSummary controllers.api.KafkaStateCheck.topicSummaryAction(cluster:String, consumer:String, topic:String, consumerType:String)
How to call this API thru browser or curl? This is not showing any data:
curl -H "Content-type: application/json" -H "Accept: application/json" "http://xxx:8088/api/status/KafkaCluster/test_consumer/test_topic/consumer_type/topicSummary"
Browser returns Action not found response..
but this one is showing the data: http://xxx:8088/api/status/KafkaCluster/consumersSummary
I have kafka-manager-1.3.3-3.1..
I have the same issue with the latest master (currently commit de5a2fad6c3cb28fa37e79eab1def2609a8c4fff)
curl http://mykafkamanager/api/status/mycluster/myconsumergroup/mytopic/ZK/topicSummary
returns
...
<body>
<h1>Action not found</h1>
<p id="detail">
For request 'GET /api/status/mykafkamanager/myconsumergroup/mytopic/ZK/topicSummary'
</p>
</body>
...
While
curl http://mykafkamanager/api/status/mycluster/consumersSummary
yields a json response containing an entry for myconsumergroup
...
{
"name" : "myconsumergroup",
"type" : "ZK",
"topics" : [ "mytopic" ]
}
...
http://kafkamanager/api/status/cluster/consumer_id/topic/topicSummary?consumerType=consumerType
That works @sairamvla - Thank you!
For my edification, how does the defined route in conf/routes work with that URI - i.e. what makes consumerType a query param while the others are path params?
GET /api/status/:cluster/:consumer/:topic/:consumerType/topicSummary controllers.api.KafkaStateCheck.topicSummaryAction(cluster:String, consumer:String, topic:String, consumerType:String)
(https://github.com/yahoo/kafka-manager/blob/master/conf/routes)
The same issue for me when I check km health via: curl -s http://127.0.0.1:9000/api/health
return as follow told that Action not found:
...
<body>
<h1>Action not found</h1>
<p id="detail">
For request 'GET /api/health'
</p>
</body>
...
How can I information on who has logged on to the Kafka Manager Ui? We need to track the people who are using the kafka manager ui What we need to turn to accomplish this?