* remove /api/tsdb/query
* revert changes to alert rules
* regenerate spec based on 9.0.x
(cherry picked from commit abfc711c53)
Co-authored-by: Will Browne <wbrowne@users.noreply.github.com>
This commit is contained in:
co-authored by
Will Browne
parent
e58aac1b77
commit
d344b69fbb
@@ -444,9 +444,6 @@ func (hs *HTTPServer) registerRoutes() {
|
||||
apiRoute.Get("/search/", routing.Wrap(hs.Search))
|
||||
|
||||
// metrics
|
||||
// Deprecated: use /ds/query API instead.
|
||||
apiRoute.Post("/tsdb/query", authorize(reqSignedIn, ac.EvalPermission(datasources.ActionQuery)), routing.Wrap(hs.QueryMetrics))
|
||||
|
||||
// DataSource w/ expressions
|
||||
apiRoute.Post("/ds/query", authorize(reqSignedIn, ac.EvalPermission(datasources.ActionQuery)), routing.Wrap(hs.QueryMetricsV2))
|
||||
|
||||
|
||||
@@ -3,7 +3,6 @@ package definitions
|
||||
import (
|
||||
"github.com/grafana/grafana/pkg/api/dtos"
|
||||
"github.com/grafana/grafana/pkg/models"
|
||||
"github.com/grafana/grafana/pkg/tsdb/legacydata"
|
||||
)
|
||||
|
||||
// swagger:route GET /datasources datasources getDatasources
|
||||
@@ -334,29 +333,6 @@ import (
|
||||
// 404: notFoundError
|
||||
// 500: internalServerError
|
||||
|
||||
// swagger:route POST /tsdb/query datasources queryDatasource
|
||||
//
|
||||
// Query metrics.
|
||||
//
|
||||
// Please refer to [updated API](#/ds/queryMetricsWithExpressions) instead
|
||||
//
|
||||
// Queries a data source having backend implementation.
|
||||
//
|
||||
// Most of Grafana’s builtin data sources have backend implementation.
|
||||
//
|
||||
// If you are running Grafana Enterprise and have Fine-grained access control enabled
|
||||
// you need to have a permission with action: `datasources:query`.
|
||||
//
|
||||
// Deprecated: true
|
||||
//
|
||||
// Responses:
|
||||
// 200: queryDatasourceResponse
|
||||
// 401: unauthorisedError
|
||||
// 400: badRequestError
|
||||
// 403: forbiddenError
|
||||
// 404: notFoundError
|
||||
// 500: internalServerError
|
||||
|
||||
// swagger:parameters updateDatasourceByID deleteDatasourceByID getDatasourceByID datasourceProxyGETcalls datasourceProxyPOSTcalls datasourceProxyDELETEcalls
|
||||
// swagger:parameters enablePermissions disablePermissions getPermissions deletePermissions
|
||||
// swagger:parameters checkDatasourceHealthByID fetchDatasourceResourcesByID
|
||||
@@ -411,13 +387,6 @@ type UpdateDatasource struct {
|
||||
Body models.UpdateDataSourceCommand
|
||||
}
|
||||
|
||||
// swagger:parameters queryDatasource
|
||||
type QueryDatasource struct {
|
||||
// in:body
|
||||
// required:true
|
||||
Body dtos.MetricRequest
|
||||
}
|
||||
|
||||
// swagger:response getDatasourcesResponse
|
||||
type GetDatasourcesResponse struct {
|
||||
// The response message
|
||||
@@ -486,11 +455,3 @@ type DeleteDatasourceByNameResponse struct {
|
||||
Message string `json:"message"`
|
||||
} `json:"body"`
|
||||
}
|
||||
|
||||
// swagger:response queryDatasourceResponse
|
||||
type QueryDatasourceResponse struct {
|
||||
// The response message
|
||||
// in: body
|
||||
//nolint: staticcheck // plugins.DataResponse deprecated
|
||||
Body legacydata.DataResponse `json:"body"`
|
||||
}
|
||||
|
||||
@@ -12,7 +12,6 @@ import (
|
||||
"github.com/grafana/grafana/pkg/plugins/backendplugin"
|
||||
"github.com/grafana/grafana/pkg/services/featuremgmt"
|
||||
"github.com/grafana/grafana/pkg/services/query"
|
||||
"github.com/grafana/grafana/pkg/tsdb/legacydata"
|
||||
"github.com/grafana/grafana/pkg/util"
|
||||
"github.com/grafana/grafana/pkg/web"
|
||||
)
|
||||
@@ -53,54 +52,6 @@ func (hs *HTTPServer) QueryMetricsV2(c *models.ReqContext) response.Response {
|
||||
return hs.toJsonStreamingResponse(resp)
|
||||
}
|
||||
|
||||
// QueryMetrics returns query metrics
|
||||
// POST /api/tsdb/query
|
||||
//nolint: staticcheck // legacydata.DataResponse deprecated
|
||||
//nolint: staticcheck // legacydata.DataQueryResult deprecated
|
||||
// Deprecated: use QueryMetricsV2 instead.
|
||||
func (hs *HTTPServer) QueryMetrics(c *models.ReqContext) response.Response {
|
||||
reqDto := dtos.MetricRequest{}
|
||||
if err := web.Bind(c.Req, &reqDto); err != nil {
|
||||
return response.Error(http.StatusBadRequest, "bad request data", err)
|
||||
}
|
||||
|
||||
sdkResp, err := hs.queryDataService.QueryData(c.Req.Context(), c.SignedInUser, c.SkipCache, reqDto, false)
|
||||
if err != nil {
|
||||
return hs.handleQueryMetricsError(err)
|
||||
}
|
||||
|
||||
legacyResp := legacydata.DataResponse{
|
||||
Results: map[string]legacydata.DataQueryResult{},
|
||||
}
|
||||
|
||||
for refID, res := range sdkResp.Responses {
|
||||
dqr := legacydata.DataQueryResult{
|
||||
RefID: refID,
|
||||
}
|
||||
|
||||
if res.Error != nil {
|
||||
dqr.Error = res.Error
|
||||
}
|
||||
|
||||
if res.Frames != nil {
|
||||
dqr.Dataframes = legacydata.NewDecodedDataFrames(res.Frames)
|
||||
}
|
||||
|
||||
legacyResp.Results[refID] = dqr
|
||||
}
|
||||
|
||||
statusCode := http.StatusOK
|
||||
for _, res := range legacyResp.Results {
|
||||
if res.Error != nil {
|
||||
res.ErrorString = res.Error.Error()
|
||||
legacyResp.Message = res.ErrorString
|
||||
statusCode = http.StatusBadRequest
|
||||
}
|
||||
}
|
||||
|
||||
return response.JSON(statusCode, &legacyResp)
|
||||
}
|
||||
|
||||
func (hs *HTTPServer) toJsonStreamingResponse(qdr *backend.QueryDataResponse) response.Response {
|
||||
statusWhenError := http.StatusBadRequest
|
||||
if hs.Features.IsEnabled(featuremgmt.FlagDatasourceQueryMultiStatus) {
|
||||
|
||||
Reference in New Issue
Block a user