From 92d47a8d8fdb9c9cd2bf50ac7df06b3ae5e86152 Mon Sep 17 00:00:00 2001 From: Andrej Ocenas Date: Fri, 28 Apr 2023 19:53:46 +0200 Subject: [PATCH] Pyroscope: Fix autodetection in case of using Phlare backend (#67536) --- pkg/tsdb/phlare/instance.go | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/pkg/tsdb/phlare/instance.go b/pkg/tsdb/phlare/instance.go index 04f101f123c..f89295f8df5 100644 --- a/pkg/tsdb/phlare/instance.go +++ b/pkg/tsdb/phlare/instance.go @@ -172,13 +172,17 @@ func (d *PhlareDatasource) backendType(ctx context.Context, req *backend.CallRes query := u.Query() body := &BackendTypeRespBody{BackendType: "unknown"} - pyroClient := getClient("pyroscope", d.httpClient, query["url"][0]) + // We take the url from the request query because the data source may not yet be saved in DB with the URL we want + // to test with (like when filling in the confgi page for the first time) + url := query["url"][0] + + pyroClient := getClient("pyroscope", d.httpClient, url) _, err = pyroClient.ProfileTypes(ctx) if err == nil { body.BackendType = "pyroscope" } else { - phlareClient := getClient("phlare", d.httpClient, d.settings.URL) + phlareClient := getClient("phlare", d.httpClient, url) _, err := phlareClient.ProfileTypes(ctx) if err == nil { body.BackendType = "phlare"