Skip to content

Commit

Permalink
DEV-46209 - Fix LogzioHeaders in Queries APIs (#38)
Browse files Browse the repository at this point in the history
The way the logzio headers are being fetched in the clients was changed,
but wasn't added in all places that were adding the headers.

This caused the elasticsearch datasources not to work because these headers are needed for these requests.
  • Loading branch information
yasmin-tr authored Aug 27, 2024
1 parent d644078 commit 43c1afd
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 3 deletions.
3 changes: 2 additions & 1 deletion pkg/api/metrics.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ import (
"github.com/grafana/grafana/pkg/api/routing"
"github.com/grafana/grafana/pkg/infra/appcontext"
"github.com/grafana/grafana/pkg/middleware/requestmeta"
"github.com/grafana/grafana/pkg/models" // LOGZ.IO GRAFANA CHANGE :: DEV-43889 - Add headers for logzio datasources support
"github.com/grafana/grafana/pkg/services/apiserver/endpoints/request"
contextmodel "github.com/grafana/grafana/pkg/services/contexthandler/model"
"github.com/grafana/grafana/pkg/services/datasources"
Expand Down Expand Up @@ -79,7 +80,7 @@ func (hs *HTTPServer) QueryMetricsV2(c *contextmodel.ReqContext) response.Respon
}

// LOGZ.IO GRAFANA CHANGE :: DEV-43889 - Add headers for logzio datasources support
ctxWithLogzHeaders := context.WithValue(c.Req.Context(), "logzioHeaders", c.Req.Header)
ctxWithLogzHeaders := models.WithLogzHeaders(c.Req.Context(), c.Req.Header)
resp, err := hs.queryDataService.QueryData(ctxWithLogzHeaders, c.SignedInUser, c.SkipDSCache, reqDTO)
// LOGZ.IO GRAFANA CHANGE :: End
if err != nil {
Expand Down
5 changes: 3 additions & 2 deletions pkg/services/ngalert/api/api_testing.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ import (
"github.com/grafana/grafana/pkg/api/response"
"github.com/grafana/grafana/pkg/infra/log"
"github.com/grafana/grafana/pkg/infra/tracing"
m "github.com/grafana/grafana/pkg/models" // LOGZ.IO GRAFANA CHANGE :: DEV-43889 - Add headers for logzio datasources support
"github.com/grafana/grafana/pkg/services/auth/identity"
contextmodel "github.com/grafana/grafana/pkg/services/contexthandler/model"
"github.com/grafana/grafana/pkg/services/dashboards"
Expand Down Expand Up @@ -84,7 +85,7 @@ func (srv TestingApiSrv) RouteTestGrafanaRuleConfig(c *contextmodel.ReqContext,
}

// LOGZ.IO GRAFANA CHANGE :: DEV-43889 - Add headers for logzio datasources support
ctxWithLogzHeaders := context.WithValue(c.Req.Context(), "logzioHeaders", c.Req.Header)
ctxWithLogzHeaders := m.WithLogzHeaders(c.Req.Context(), c.Req.Header)
evaluator, err := srv.evaluator.Create(eval.NewContext(ctxWithLogzHeaders, c.SignedInUser), rule.GetEvalCondition())
// LOGZ.IO GRAFANA CHANGE :: End
if err != nil {
Expand Down Expand Up @@ -187,7 +188,7 @@ func (srv TestingApiSrv) RouteEvalQueries(c *contextmodel.ReqContext, cmd apimod
}

// LOGZ.IO GRAFANA CHANGE :: DEV-43889 - Add headers for logzio datasources support
ctxWithLogzHeaders := context.WithValue(c.Req.Context(), "logzioHeaders", c.Req.Header)
ctxWithLogzHeaders := m.WithLogzHeaders(c.Req.Context(), c.Req.Header)
evaluator, err := srv.evaluator.Create(eval.NewContext(ctxWithLogzHeaders, c.SignedInUser), cond)
// LOGZ.IO GRAFANA CHANGE :: End

Expand Down

0 comments on commit 43c1afd

Please sign in to comment.