This commit is contained in:
Sebastien Blot 2022-11-28 14:20:22 +01:00 committed by lperdereau
parent 2195509218
commit 8f3a20b7a4
2 changed files with 6 additions and 6 deletions

View file

@ -5,7 +5,7 @@ import (
"encoding/base64" "encoding/base64"
"encoding/json" "encoding/json"
"fmt" "fmt"
"io/ioutil" "io"
"net/http" "net/http"
"net/url" "net/url"
"strconv" "strconv"
@ -83,8 +83,8 @@ func (lc *LokiClient) queryRange(uri string, ctx context.Context, c chan *LokiQu
if err != nil { if err != nil {
return errors.Wrapf(err, "error querying range") return errors.Wrapf(err, "error querying range")
} }
if resp.StatusCode != 200 { if resp.StatusCode != http.StatusOK {
body, _ := ioutil.ReadAll(resp.Body) body, _ := io.ReadAll(resp.Body)
resp.Body.Close() resp.Body.Close()
return errors.Wrapf(err, "bad HTTP response code: %d: %s", resp.StatusCode, string(body)) return errors.Wrapf(err, "bad HTTP response code: %d: %s", resp.StatusCode, string(body))
} }
@ -166,7 +166,7 @@ func (lc *LokiClient) Ready(ctx context.Context) error {
continue continue
} }
_ = resp.Body.Close() _ = resp.Body.Close()
if resp.StatusCode != 200 { if resp.StatusCode != http.StatusOK {
lc.Logger.Debugf("Loki is not ready, status code: %d", resp.StatusCode) lc.Logger.Debugf("Loki is not ready, status code: %d", resp.StatusCode)
continue continue
} }
@ -204,7 +204,7 @@ func (lc *LokiClient) Tail(ctx context.Context) (chan *LokiResponse, error) {
defer resp.Body.Close() defer resp.Body.Close()
if err != nil { if err != nil {
if resp != nil { if resp != nil {
buf, err2 := ioutil.ReadAll(resp.Body) buf, err2 := io.ReadAll(resp.Body)
if err2 != nil { if err2 != nil {
return nil, fmt.Errorf("error reading response body while handling WS error: %s (%s)", err, err2) return nil, fmt.Errorf("error reading response body while handling WS error: %s (%s)", err, err2)
} }

View file

@ -92,7 +92,7 @@ func (l *LokiSource) Configure(config []byte, logger *log.Entry) error {
} }
if !strings.HasSuffix(l.Config.Prefix, "/") { if !strings.HasSuffix(l.Config.Prefix, "/") {
l.Config.Prefix = l.Config.Prefix + "/" l.Config.Prefix += "/"
} }
if l.Config.Limit == 0 { if l.Config.Limit == 0 {