Skip to content

Commit

Permalink
Escape Prometheus querystring (#521)
Browse files Browse the repository at this point in the history
* Escape Prometheus querystring

* Fix typo
  • Loading branch information
samjo-nyang authored and ahmelsayed committed Jan 6, 2020
1 parent 61d7959 commit 76f4cf1
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion pkg/scalers/prometheus.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import (
"fmt"
"io/ioutil"
"net/http"
url_pkg "net/url"
"strconv"
"time"

Expand Down Expand Up @@ -122,7 +123,8 @@ func (s *prometheusScaler) GetMetricSpecForScaling() []v2beta1.MetricSpec {

func (s *prometheusScaler) ExecutePromQuery() (float64, error) {
t := time.Now().UTC().Format(time.RFC3339)
url := fmt.Sprintf("%s/api/v1/query?query=%s&time=%s", s.metadata.serverAddress, s.metadata.query, t)
query_escaped := url_pkg.QueryEscape(s.metadata.query)
url := fmt.Sprintf("%s/api/v1/query?query=%s&time=%s", s.metadata.serverAddress, query_escaped, t)
r, err := http.Get(url)
if err != nil {
return -1, err
Expand Down

0 comments on commit 76f4cf1

Please sign in to comment.