mirror of
https://github.com/grafana/grafana.git
synced 2025-02-25 18:55:37 -06:00
Search: create a separate HTTP endpoint (#55634)
* search: create a separate http endpoint * search: extract api uri * search: rename uri * search: replicate the readiness check * search: replicate the readiness check metric * search: update mock
This commit is contained in:
@@ -24,8 +24,17 @@ import (
|
||||
)
|
||||
|
||||
var (
|
||||
namespace = "grafana"
|
||||
subsystem = "search"
|
||||
namespace = "grafana"
|
||||
subsystem = "search"
|
||||
dashboardSearchNotServedRequestsCounter = promauto.NewCounterVec(
|
||||
prometheus.CounterOpts{
|
||||
Namespace: namespace,
|
||||
Subsystem: subsystem,
|
||||
Name: "dashboard_search_requests_not_served_total",
|
||||
Help: "A counter for dashboard search requests that could not be served due to an ongoing search engine indexing",
|
||||
},
|
||||
[]string{"reason"},
|
||||
)
|
||||
dashboardSearchFailureRequestsCounter = promauto.NewCounterVec(
|
||||
prometheus.CounterOpts{
|
||||
Namespace: namespace,
|
||||
@@ -194,7 +203,21 @@ func (s *StandardSearchService) getUser(ctx context.Context, backendUser *backen
|
||||
|
||||
func (s *StandardSearchService) DoDashboardQuery(ctx context.Context, user *backend.User, orgID int64, q DashboardQuery) *backend.DataResponse {
|
||||
start := time.Now()
|
||||
query := s.doDashboardQuery(ctx, user, orgID, q)
|
||||
|
||||
signedInUser, err := s.getUser(ctx, user, orgID)
|
||||
|
||||
if err != nil {
|
||||
dashboardSearchFailureRequestsCounter.With(prometheus.Labels{
|
||||
"reason": "get_user_error",
|
||||
}).Inc()
|
||||
|
||||
duration := time.Since(start).Seconds()
|
||||
dashboardSearchFailureRequestsDuration.Observe(duration)
|
||||
|
||||
return &backend.DataResponse{Error: err}
|
||||
}
|
||||
|
||||
query := s.doDashboardQuery(ctx, signedInUser, orgID, q)
|
||||
|
||||
duration := time.Since(start).Seconds()
|
||||
if query.Error != nil {
|
||||
@@ -206,16 +229,8 @@ func (s *StandardSearchService) DoDashboardQuery(ctx context.Context, user *back
|
||||
return query
|
||||
}
|
||||
|
||||
func (s *StandardSearchService) doDashboardQuery(ctx context.Context, user *backend.User, orgID int64, q DashboardQuery) *backend.DataResponse {
|
||||
func (s *StandardSearchService) doDashboardQuery(ctx context.Context, signedInUser *user.SignedInUser, orgID int64, q DashboardQuery) *backend.DataResponse {
|
||||
rsp := &backend.DataResponse{}
|
||||
signedInUser, err := s.getUser(ctx, user, orgID)
|
||||
if err != nil {
|
||||
dashboardSearchFailureRequestsCounter.With(prometheus.Labels{
|
||||
"reason": "get_user_error",
|
||||
}).Inc()
|
||||
rsp.Error = err
|
||||
return rsp
|
||||
}
|
||||
|
||||
filter, err := s.auth.GetDashboardReadFilter(signedInUser)
|
||||
if err != nil {
|
||||
|
||||
Reference in New Issue
Block a user