Skip to content

Commit

Permalink
chore: query, response update
Browse files Browse the repository at this point in the history
  • Loading branch information
shivanshuraj1333 committed Aug 26, 2024
1 parent 413caad commit f508ee7
Show file tree
Hide file tree
Showing 3 changed files with 93 additions and 282 deletions.
32 changes: 20 additions & 12 deletions pkg/query-service/app/http_handler.go
Original file line number Diff line number Diff line change
Expand Up @@ -2534,17 +2534,16 @@ func (aH *APIHandler) getNetworkData(
RespondError(w, apiErrObj, errQuriesByName)
return
}
result = postprocess.TransformToTableForClickHouseQueries(result)

// iterate over the result and extract messaging.client_id
for _, res := range result {
table := res.Table
for _, row := range table.Rows {
if row.Data["client_id"] != nil && row.Data["service_instance_id"] != nil && row.Data["service_name"] != nil {
clientID := row.Data["client_id"].(string)
serviceInstanceId := row.Data["service_instance_id"].(string)
ServiceName := row.Data["service_name"].(string)
attributeCache = append(attributeCache, mq.Clients{ClientID: clientID, ServiceInstanceID: serviceInstanceId, ServiceName: ServiceName})
for _, series := range res.Series {
clientID, clientIDOk := series.Labels["client_id"]
serviceInstanceID, serviceInstanceIDOk := series.Labels["service_instance_id"]
serviceName, serviceNameOk := series.Labels["service_name"]
if clientIDOk && serviceInstanceIDOk && serviceNameOk {
attributeCache = append(attributeCache, mq.Clients{ClientID: clientID,
ServiceInstanceID: serviceInstanceID,
ServiceName: serviceName})
}
}
}
Expand All @@ -2567,12 +2566,21 @@ func (aH *APIHandler) getNetworkData(
RespondError(w, apiErrObj, errQuriesByNameFetchLatency)
return
}
resultFetchLatency = postprocess.TransformToTableForClickHouseQueries(resultFetchLatency)

result = append(result, resultFetchLatency...)
latencyColoumn := &v3.Result{QueryName: "latency"}
var latencySeries []*v3.Series
for _, res := range resultFetchLatency {
for _, series := range res.Series {
latencySeries = append(latencySeries, series)
}
}
latencyColoumn.Series = latencySeries
result = append(result, latencyColoumn)

resultFetchLatency = postprocess.TransformToTableForBuilderQueries(result, queryRangeParams)

resp := v3.QueryRangeResponse{
Result: result,
Result: resultFetchLatency,
}
aH.Respond(w, resp)
}
Expand Down
Loading

0 comments on commit f508ee7

Please sign in to comment.