properly build URL
This commit is contained in:
parent
3f56a0759f
commit
2195509218
|
@ -8,7 +8,6 @@ import (
|
||||||
"io/ioutil"
|
"io/ioutil"
|
||||||
"net/http"
|
"net/http"
|
||||||
"net/url"
|
"net/url"
|
||||||
"path/filepath"
|
|
||||||
"strconv"
|
"strconv"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
|
@ -107,7 +106,7 @@ func (lc *LokiClient) queryRange(uri string, ctx context.Context, c chan *LokiQu
|
||||||
//Can we assume we will always have only one stream?
|
//Can we assume we will always have only one stream?
|
||||||
lastTs := lq.Data.Result[0].Entries[len(lq.Data.Result[0].Entries)-1].Timestamp
|
lastTs := lq.Data.Result[0].Entries[len(lq.Data.Result[0].Entries)-1].Timestamp
|
||||||
|
|
||||||
lc.Logger.Infof("Got %d results, last timestamp: %s (converted: %d)", len(lq.Data.Result[0].Entries), lastTs, strconv.Itoa(lastTs.Nanosecond()))
|
lc.Logger.Infof("Got %d results, last timestamp: %s (converted: %s)", len(lq.Data.Result[0].Entries), lastTs, strconv.Itoa(lastTs.Nanosecond()))
|
||||||
u, err := url.Parse(uri) //we can ignore the error, we know it's valid
|
u, err := url.Parse(uri) //we can ignore the error, we know it's valid
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return errors.Wrapf(err, "error parsing URL")
|
return errors.Wrapf(err, "error parsing URL")
|
||||||
|
@ -131,7 +130,11 @@ func (lc *LokiClient) getURLFor(endpoint string, params map[string]string) strin
|
||||||
}
|
}
|
||||||
u.RawQuery = queryParams.Encode()
|
u.RawQuery = queryParams.Encode()
|
||||||
|
|
||||||
u.Path = filepath.Join(lc.config.LokiPrefix, u.Path, endpoint)
|
u.Path, err = url.JoinPath(lc.config.LokiPrefix, u.Path, endpoint)
|
||||||
|
|
||||||
|
if err != nil {
|
||||||
|
return ""
|
||||||
|
}
|
||||||
|
|
||||||
switch endpoint {
|
switch endpoint {
|
||||||
case "loki/api/v1/tail":
|
case "loki/api/v1/tail":
|
||||||
|
|
Loading…
Reference in a new issue