Skip to content

Commit 43c1afd

Browse files
authored
DEV-46209 - Fix LogzioHeaders in Queries APIs (#38)
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.
1 parent d644078 commit 43c1afd

File tree

2 files changed

+5
-3
lines changed

2 files changed

+5
-3
lines changed

pkg/api/metrics.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ import (
1313
"github.com/grafana/grafana/pkg/api/routing"
1414
"github.com/grafana/grafana/pkg/infra/appcontext"
1515
"github.com/grafana/grafana/pkg/middleware/requestmeta"
16+
"github.com/grafana/grafana/pkg/models" // LOGZ.IO GRAFANA CHANGE :: DEV-43889 - Add headers for logzio datasources support
1617
"github.com/grafana/grafana/pkg/services/apiserver/endpoints/request"
1718
contextmodel "github.com/grafana/grafana/pkg/services/contexthandler/model"
1819
"github.com/grafana/grafana/pkg/services/datasources"
@@ -79,7 +80,7 @@ func (hs *HTTPServer) QueryMetricsV2(c *contextmodel.ReqContext) response.Respon
7980
}
8081

8182
// LOGZ.IO GRAFANA CHANGE :: DEV-43889 - Add headers for logzio datasources support
82-
ctxWithLogzHeaders := context.WithValue(c.Req.Context(), "logzioHeaders", c.Req.Header)
83+
ctxWithLogzHeaders := models.WithLogzHeaders(c.Req.Context(), c.Req.Header)
8384
resp, err := hs.queryDataService.QueryData(ctxWithLogzHeaders, c.SignedInUser, c.SkipDSCache, reqDTO)
8485
// LOGZ.IO GRAFANA CHANGE :: End
8586
if err != nil {

pkg/services/ngalert/api/api_testing.go

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ import (
1919
"github.com/grafana/grafana/pkg/api/response"
2020
"github.com/grafana/grafana/pkg/infra/log"
2121
"github.com/grafana/grafana/pkg/infra/tracing"
22+
m "github.com/grafana/grafana/pkg/models" // LOGZ.IO GRAFANA CHANGE :: DEV-43889 - Add headers for logzio datasources support
2223
"github.com/grafana/grafana/pkg/services/auth/identity"
2324
contextmodel "github.com/grafana/grafana/pkg/services/contexthandler/model"
2425
"github.com/grafana/grafana/pkg/services/dashboards"
@@ -84,7 +85,7 @@ func (srv TestingApiSrv) RouteTestGrafanaRuleConfig(c *contextmodel.ReqContext,
8485
}
8586

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

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

0 commit comments

Comments
 (0)