mirror of
https://github.com/grafana/grafana.git
synced 2025-01-10 08:03:58 -06:00
Loki: Remove API restrictions on resource calls (#85191)
Loki: Remove API restrictions
This commit is contained in:
parent
1513b0cab1
commit
c80b31a0d4
@ -6,7 +6,6 @@ import (
|
||||
"fmt"
|
||||
"net/http"
|
||||
"regexp"
|
||||
"strings"
|
||||
"sync"
|
||||
"time"
|
||||
|
||||
@ -120,18 +119,7 @@ func (s *Service) CallResource(ctx context.Context, req *backend.CallResourceReq
|
||||
|
||||
func callResource(ctx context.Context, req *backend.CallResourceRequest, sender backend.CallResourceResponseSender, dsInfo *datasourceInfo, plog log.Logger, tracer tracing.Tracer) error {
|
||||
url := req.URL
|
||||
// a very basic is-this-url-valid check
|
||||
if req.Method != "GET" {
|
||||
plog.Error("Invalid HTTP method", "method", req.Method)
|
||||
return fmt.Errorf("invalid HTTP method: %s", req.Method)
|
||||
}
|
||||
if (!strings.HasPrefix(url, "labels?")) &&
|
||||
(!strings.HasPrefix(url, "label/")) && // the `/label/$label_name/values` form
|
||||
(!strings.HasPrefix(url, "series?")) &&
|
||||
(!strings.HasPrefix(url, "index/stats?")) {
|
||||
plog.Error("Invalid URL", "url", url)
|
||||
return fmt.Errorf("invalid URL: %s", url)
|
||||
}
|
||||
|
||||
lokiURL := fmt.Sprintf("/loki/api/v1/%s", url)
|
||||
|
||||
ctx, span := tracer.Start(ctx, "datasource.loki.CallResource", trace.WithAttributes(
|
||||
|
Loading…
Reference in New Issue
Block a user