diff --git a/pkg/ruler/base/ruler.go b/pkg/ruler/base/ruler.go index adb1a7c136def..4e466810570b1 100644 --- a/pkg/ruler/base/ruler.go +++ b/pkg/ruler/base/ruler.go @@ -407,9 +407,9 @@ func grafanaLinkForExpression(expr, datasourceUID string) string { } marshaledExpression, _ := json.Marshal(exprStruct) - escapedExpression := url.QueryEscape(string(marshaledExpression)) - str := `/explore?left={"queries":[%s]}` - return fmt.Sprintf(str, escapedExpression) + params := url.Values{} + params.Set("left", fmt.Sprintf(`{"queries":[%s]}`, marshaledExpression)) + return `/explore?` + params.Encode() } // SendAlerts implements a rules.NotifyFunc for a Notifier. diff --git a/pkg/ruler/base/ruler_test.go b/pkg/ruler/base/ruler_test.go index bdb437ed9279d..6636f742456a2 100644 --- a/pkg/ruler/base/ruler_test.go +++ b/pkg/ruler/base/ruler_test.go @@ -1733,7 +1733,7 @@ func TestSendAlerts(t *testing.T) { Annotations: []labels.Label{{Name: "a2", Value: "v2"}}, StartsAt: time.Unix(2, 0), EndsAt: time.Unix(3, 0), - GeneratorURL: fmt.Sprintf("http://localhost:8080/explore?left={\"queries\":[%s]}", escapedExpression), + GeneratorURL: fmt.Sprintf("http://localhost:8080/explore?left=%%7B%%22queries%%22%%3A%%5B%s%%5D%%7D", escapedExpression), }, }, }, @@ -1753,7 +1753,7 @@ func TestSendAlerts(t *testing.T) { Annotations: []labels.Label{{Name: "a2", Value: "v2"}}, StartsAt: time.Unix(2, 0), EndsAt: time.Unix(4, 0), - GeneratorURL: fmt.Sprintf("http://localhost:8080/explore?left={\"queries\":[%s]}", escapedExpression), + GeneratorURL: fmt.Sprintf("http://localhost:8080/explore?left=%%7B%%22queries%%22%%3A%%5B%s%%5D%%7D", escapedExpression), }, }, },