From 74fef637afae46ade7801617f04814f83306f513 Mon Sep 17 00:00:00 2001 From: Ivana Huckova <30407135+ivanahuckova@users.noreply.github.com> Date: Mon, 23 Aug 2021 09:25:40 -0400 Subject: [PATCH] Prometheus: Use default POST method if no httpMethod provided (#38446) * Prometheus: If no httpMethod, use default POST method * Use http.MethodPost --- pkg/tsdb/prometheus/prometheus.go | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/pkg/tsdb/prometheus/prometheus.go b/pkg/tsdb/prometheus/prometheus.go index bebdfc9e432..abf09a33359 100644 --- a/pkg/tsdb/prometheus/prometheus.go +++ b/pkg/tsdb/prometheus/prometheus.go @@ -5,6 +5,7 @@ import ( "encoding/json" "errors" "fmt" + "net/http" "regexp" "strings" "time" @@ -70,6 +71,7 @@ func (s *Service) Init() error { func newInstanceSettings() datasource.InstanceFactoryFunc { return func(settings backend.DataSourceInstanceSettings) (instancemgmt.Instance, error) { + defaultHttpMethod := http.MethodPost jsonData := map[string]interface{}{} err := json.Unmarshal(settings.JSONData, &jsonData) if err != nil { @@ -82,7 +84,7 @@ func newInstanceSettings() datasource.InstanceFactoryFunc { httpMethod, ok := jsonData["httpMethod"].(string) if !ok { - return nil, errors.New("no http method provided") + httpMethod = defaultHttpMethod } // timeInterval can be a string or can be missing.