chore: keep anomaly response sync with v4 query range (#6113)

This commit is contained in:
Srikanth Chekuri 2024-10-08 13:33:33 +05:30 committed by GitHub
parent 76e7de3aed
commit 4356ddae8c
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 4 additions and 6 deletions

View File

@ -106,12 +106,11 @@ func (aH *APIHandler) queryRangeV4(w http.ResponseWriter, r *http.Request) {
RespondError(w, &model.ApiError{Typ: model.ErrorInternal, Err: err}, nil) RespondError(w, &model.ApiError{Typ: model.ErrorInternal, Err: err}, nil)
return return
} }
uniqueResults := make(map[string]*v3.Result) resp := v3.QueryRangeResponse{
for _, anomaly := range anomalies.Results { Result: anomalies.Results,
uniqueResults[anomaly.QueryName] = anomaly ResultType: "anomaly",
uniqueResults[anomaly.QueryName].IsAnomaly = true
} }
aH.Respond(w, uniqueResults) aH.Respond(w, resp)
} else { } else {
r.Body = io.NopCloser(bytes.NewBuffer(bodyBytes)) r.Body = io.NopCloser(bytes.NewBuffer(bodyBytes))
aH.QueryRangeV4(w, r) aH.QueryRangeV4(w, r)

View File

@ -1158,7 +1158,6 @@ type Result struct {
AnomalyScores []*Series `json:"anomalyScores,omitempty"` AnomalyScores []*Series `json:"anomalyScores,omitempty"`
List []*Row `json:"list,omitempty"` List []*Row `json:"list,omitempty"`
Table *Table `json:"table,omitempty"` Table *Table `json:"table,omitempty"`
IsAnomaly bool `json:"isAnomaly,omitempty"`
} }
type Series struct { type Series struct {