From 93fbd40e2fb930ed288f57aafb361f3dfbb1fd5b Mon Sep 17 00:00:00 2001 From: woodsaj <awoods@raintank.io> Date: Wed, 6 Feb 2019 14:40:50 +0800 Subject: [PATCH] fix promtail_request_duration metric --- pkg/promtail/client/client.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/pkg/promtail/client/client.go b/pkg/promtail/client/client.go index 38d7800e..7f447524 100644 --- a/pkg/promtail/client/client.go +++ b/pkg/promtail/client/client.go @@ -154,13 +154,13 @@ func (c *Client) send(batch map[model.Fingerprint]*logproto.Stream) error { start := time.Now() resp, err := http.Post(c.cfg.URL.String(), contentType, bytes.NewReader(buf)) if err != nil { - requestDuration.WithLabelValues("failed").Observe(time.Until(start).Seconds()) + requestDuration.WithLabelValues("failed").Observe(time.Since(start).Seconds()) return err } if err := resp.Body.Close(); err != nil { return err } - requestDuration.WithLabelValues(strconv.Itoa(resp.StatusCode)).Observe(time.Until(start).Seconds()) + requestDuration.WithLabelValues(strconv.Itoa(resp.StatusCode)).Observe(time.Since(start).Seconds()) if resp.StatusCode/100 != 2 { return fmt.Errorf("Error doing write: %d - %s", resp.StatusCode, resp.Status) -- GitLab