From 98cbdf570fc319877b9673138bcd421f9ce10cc0 Mon Sep 17 00:00:00 2001 From: shivanshu Date: Fri, 4 Oct 2024 01:44:52 +0530 Subject: [PATCH] feat: api documentation and nits --- pkg/query-service/app/http_handler.go | 12 +- .../messagingQueues/kafka/consumerLag.md | 329 ++++++++++++++---- 2 files changed, 276 insertions(+), 65 deletions(-) diff --git a/pkg/query-service/app/http_handler.go b/pkg/query-service/app/http_handler.go index 261b3d96df..7078566eca 100644 --- a/pkg/query-service/app/http_handler.go +++ b/pkg/query-service/app/http_handler.go @@ -2600,7 +2600,7 @@ func (aH *APIHandler) onboardConsumers( return } - chq, err := mq.BuildClickHouseQuery(messagingQueue, mq.KafkaQueue, "onboard_producers") + chq, err := mq.BuildClickHouseQuery(messagingQueue, mq.KafkaQueue, "onboard_consumers") if err != nil { zap.L().Error(err.Error()) @@ -2650,7 +2650,7 @@ func (aH *APIHandler) onboardConsumers( attribute = "kind" if intValue != 0 { status = "0" - message = "check if your producer spans has kind=4 as attribute" + message = "check if your consumer spans has kind=5 as attribute" } else { status = "1" } @@ -2721,6 +2721,10 @@ func (aH *APIHandler) onboardConsumers( } } + sort.Slice(entries, func(i, j int) bool { + return entries[i].Attribute < entries[j].Attribute + }) + aH.Respond(w, entries) } @@ -2801,6 +2805,10 @@ func (aH *APIHandler) onboardKafka( } } + sort.Slice(entries, func(i, j int) bool { + return entries[i].Attribute < entries[j].Attribute + }) + aH.Respond(w, entries) } diff --git a/pkg/query-service/app/integrations/messagingQueues/kafka/consumerLag.md b/pkg/query-service/app/integrations/messagingQueues/kafka/consumerLag.md index 2d4b80ac40..d338a9acb9 100644 --- a/pkg/query-service/app/integrations/messagingQueues/kafka/consumerLag.md +++ b/pkg/query-service/app/integrations/messagingQueues/kafka/consumerLag.md @@ -230,89 +230,292 @@ Response in query range `table` format ### Onboarding APIs ``` -/api/v1/messaging-queues/kafka/consumer-lag/onboarding-producers +/api/v1/messaging-queues/kafka/onboarding/producers ``` +```json +{ + "start": 1727620544260611424, + "end": 1727620556401481428 +} ``` + +```json +// everything is present { "status": "success", - "data": { - "resultType": "", - "result": [ - { - "queryName": "onboard_producers", - "series": [ - { - "labels": {}, - "labelsArray": [ - { - "result": "All attributes are present and meet the conditions" - } - ], - "values": [] - } - ] - } - ] - } + "data": [ + { + "attribute": "kind", + "error_message": "", + "status": "1" + }, + { + "attribute": "messaging.destination.name", + "error_message": "", + "status": "1" + }, + { + "attribute": "messaging.destination.partition.id", + "error_message": "messaging.destination.partition.id attribute is not present in your spans", + "status": "0" + }, + { + "attribute": "messaging.system", + "error_message": "", + "status": "1" + }, + { + "attribute": "telemetry ingestion", + "error_message": "", + "status": "1" + } + ] +} + +// partial attributes are present +{ + "status": "success", + "data": [ + { + "attribute": "kind", + "error_message": "", + "status": "1" + }, + { + "attribute": "messaging.destination.name", + "error_message": "messaging.destination.name attribute is not present in your spans", + "status": "0" + }, + { + "attribute": "messaging.destination.partition.id", + "error_message": "", + "status": "1" + }, + { + "attribute": "messaging.system", + "error_message": "", + "status": "1" + }, + { + "attribute": "telemetry ingestion", + "error_message": "", + "status": "1" + } + ] +} + +// no data available +{ + "status": "success", + "data": [ + { + "attribute": "telemetry ingestion", + "error_message": "No data available in the given time range", + "status": "0" + } + ] } ``` ``` -/api/v1/messaging-queues/kafka/consumer-lag/onboarding-consumers +/api/v1/messaging-queues/kafka/onboarding/consumers ``` -``` +```json +// everything is present { - "status": "success", - "data": { - "resultType": "", - "result": [ - { - "queryName": "onboard_consumers", - "series": [ - { - "labels": {}, - "labelsArray": [ - { - "result": "All attributes are present and meet the conditions" - } - ], - "values": [] - } - ] - } - ] + "status": "success", + "data": [ + { + "attribute": "kind", + "error_message": "", + "status": "1" + }, + { + "attribute": "messaging.client_id", + "error_message": "", + "status": "1" + }, + { + "attribute": "messaging.destination.name", + "error_message": "", + "status": "1" + }, + { + "attribute": "messaging.destination.partition.id", + "error_message": "", + "status": "1" + }, + { + "attribute": "messaging.kafka.consumer.group", + "error_message": "", + "status": "1" + }, + { + "attribute": "messaging.message.body.size", + "error_message": "", + "status": "1" + }, + { + "attribute": "messaging.system", + "error_message": "", + "status": "1" + }, + { + "attribute": "service.instance.id", + "error_message": "", + "status": "1" + }, + { + "attribute": "service_name", + "error_message": "", + "status": "1" + }, + { + "attribute": "telemetry ingestion", + "error_message": "", + "status": "1" } + ] +} + +// partial attributes are present +{ + "status": "success", + "data": [ + { + "attribute": "kind", + "error_message": "check if your consumer spans has kind=5 as attribute", + "status": "0" + }, + { + "attribute": "messaging.client_id", + "error_message": "", + "status": "1" + }, + { + "attribute": "messaging.destination.name", + "error_message": "", + "status": "1" + }, + { + "attribute": "messaging.destination.partition.id", + "error_message": "", + "status": "1" + }, + { + "attribute": "messaging.kafka.consumer.group", + "error_message": "messaging.kafka.consumer.group attribute is not present in your spans", + "status": "0" + }, + { + "attribute": "messaging.message.body.size", + "error_message": "messaging.message.body.size attribute is not present in your spans", + "status": "0" + }, + { + "attribute": "messaging.system", + "error_message": "", + "status": "1" + }, + { + "attribute": "service.instance.id", + "error_message": "", + "status": "1" + }, + { + "attribute": "service_name", + "error_message": "", + "status": "1" + }, + { + "attribute": "telemetry ingestion", + "error_message": "", + "status": "1" + } + ] +} + +// no data available +{ + "status": "success", + "data": [ + { + "attribute": "telemetry ingestion", + "error_message": "No data available in the given time range", + "status": "0" + } + ] } ``` ``` -127.0.0.1:8080/api/v1/messaging-queues/kafka/consumer-lag/onboarding-kafka +/api/v1/messaging-queues/kafka/onboarding/kafka ``` -``` +```json { - "status": "success", - "data": { - "resultType": "", - "result": [ - { - "queryName": "onboard_consumers", - "series": [ - { - "labels": {}, - "labelsArray": [ - { - "result": "Neither metric (kafka_consumer_fetch_latency_avg nor kafka_consumer_group_lag) is present in the given time range." - } - ], - "values": [] - } - ] - } - ] - } + "start": 1728485200000000000, + "end": 1728749800000000000 +} +``` + +```json +// everything is present +{ + "status": "success", + "data": [ + { + "attribute": "telemetry ingestion", + "error_message": "", + "status": "1" + }, + { + "attribute": "kafka_consumer_fetch_latency_avg", + "error_message": "Metric kafka_consumer_fetch_latency_avg is not present in the given time range.", + "status": "0" + }, + { + "attribute": "kafka_consumer_group_lag", + "error_message": "Metric kafka_consumer_group_lag is not present in the given time range.", + "status": "0" + } + ] +} + +// partial attributes are present +{ + "status": "success", + "data": [ + { + "attribute": "telemetry ingestion", + "error_message": "", + "status": "1" + }, + { + "attribute": "kafka_consumer_fetch_latency_avg", + "error_message": "", + "status": "1" + }, + { + "attribute": "kafka_consumer_group_lag", + "error_message": "", + "status": "1" + } + ] +} + +// no data available +{ + "status": "success", + "data": [ + { + "attribute": "telemetry ingestion", + "error_message": "No data available in the given time range", + "status": "0" + } + ] } ```