Skip to content

Commit b5c999d

Browse files
committed
fix showing logs
1 parent 4cda1c1 commit b5c999d

File tree

3 files changed

+7
-6
lines changed

3 files changed

+7
-6
lines changed

cmd/root.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ import (
3030

3131
//nolint:gochecknoinits // cobra is initialized in init()
3232
func init() {
33-
rootCmd.Flags().String("log-level", "INFO", "Logging level")
33+
rootCmd.Flags().String("log-level", "info", "Logging level")
3434
rootCmd.Flags().String("log-fmt", "logfmt", "Logging output format: logfmt|json")
3535
rootCmd.Flags().Int("port", 9191, "address the HTTP server will be listening to")
3636
rootCmd.Flags().Duration("timeout", 30*time.Second, "log request timeout")

pkg/faas/requester.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -70,9 +70,9 @@ func (l *lokiRequester) buildRequest(logReq logs.Request) (req logproto.QueryReq
7070
}
7171

7272
if logReq.Instance != "" {
73-
req.Selector = fmt.Sprintf("{faas_function=\"%s\",instance=\"%s\"}", logReq.Name, logReq.Instance)
73+
req.Selector = fmt.Sprintf("{app=\"%s\",instance=\"%s\"}", logReq.Name, logReq.Instance)
7474
} else {
75-
req.Selector = fmt.Sprintf("{faas_function=\"%s\"}", logReq.Name)
75+
req.Selector = fmt.Sprintf("{app=\"%s\"}", logReq.Name)
7676
}
7777
log.Debug().Str("method", "buildRequest").Msgf("%v => %v", logReq, req)
7878
return req

pkg/loki/client.go

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -61,10 +61,11 @@ func (c *httpClient) doRequest(ctx context.Context, path string, out interface{}
6161
}
6262
req = req.WithContext(ctx)
6363

64-
logger.Debug().Msg(req.URL.String())
64+
logger.Debug().Msgf("URL: %s", req.URL.String())
6565

6666
resp, err := c.parent.Do(req)
6767
if err != nil {
68+
logger.Debug().Err(err).Msgf("Error with request")
6869
return errors.Wrap(err, "failed request")
6970
}
7071
defer func() {
@@ -74,15 +75,15 @@ func (c *httpClient) doRequest(ctx context.Context, path string, out interface{}
7475
}
7576
}()
7677

78+
logger.Debug().Msgf("Response: %v", resp.Status)
7779
if !isOK(resp.StatusCode) {
7880
return errors.Wrap(err, "error response from server")
7981
}
80-
8182
return json.NewDecoder(resp.Body).Decode(out)
8283
}
8384

8485
func isOK(s int) bool {
85-
return s/100 == 2
86+
return s == 200 || s == 201
8687
}
8788

8889
func requestAsQueryParms(req logproto.QueryRequest) (params url.Values) {

0 commit comments

Comments
 (0)