Skip to content

Commit

Permalink
fix: Fix loki ruler generator url left parameter url encoding
Browse files Browse the repository at this point in the history
  • Loading branch information
matthewhudsonedb committed Jan 9, 2025
1 parent b2f46de commit 91a7e91
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 13 deletions.
16 changes: 8 additions & 8 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# ______ ____ __ __ _
# ______ ____ __ __ _
# / ____/________ _/ __/___ _____ ____ _ / / ____ / /__(_)
# / / __/ ___/ __ `/ /_/ __ `/ __ \/ __ `/ / / / __ \/ //_/ /
# / /_/ / / / /_/ / __/ /_/ / / / / /_/ / / /___/ /_/ / ,< / /
Expand Down Expand Up @@ -65,19 +65,19 @@ LOGQL_ANALYZER_IMAGE := $(IMAGE_PREFIX)/logql-analyzer:$(IMAGE_TAG)
OPERATOR_IMAGE := $(IMAGE_PREFIX)/loki-operator:$(IMAGE_TAG)

# OCI (Docker) setup
OCI_PLATFORMS := --platform=linux/amd64,linux/arm64
OCI_PLATFORMS := --platform=linux/amd64#,linux/arm64
OCI_BUILD_ARGS := --build-arg GO_VERSION=$(GO_VERSION) --build-arg BUILD_IMAGE=$(BUILD_IMAGE)
OCI_PUSH_ARGS := -o type=registry
OCI_PUSH := docker push
OCI_TAG := docker tag

ifeq ($(CI),true)
#ifeq ($(CI),true)
# ensure buildx is set up
_ := $(shell ./tools/ensure-buildx-builder.sh)
OCI_BUILD := DOCKER_BUILDKIT=1 docker buildx build $(OCI_PLATFORMS) $(OCI_BUILD_ARGS)
else
OCI_BUILD := DOCKER_BUILDKIT=1 docker build $(OCI_BUILD_ARGS)
endif
# _ := $(shell ./tools/ensure-buildx-builder.sh)
#OCI_BUILD := DOCKER_BUILDKIT=1 docker buildx build $(OCI_PLATFORMS) $(OCI_BUILD_ARGS)
#else
OCI_BUILD := DOCKER_BUILDKIT=1 docker build $(OCI_BUILD_ARGS) $(OCI_PLATFORMS)
#endif

BUILD_OCI_PUSH := $(OCI_BUILD) $(OCI_PUSH_ARGS)

Expand Down
6 changes: 3 additions & 3 deletions pkg/ruler/base/ruler.go
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
4 changes: 2 additions & 2 deletions pkg/ruler/base/ruler_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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),
},
},
},
Expand All @@ -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),
},
},
},
Expand Down

0 comments on commit 91a7e91

Please sign in to comment.