fix promtail_request_duration metric

pull/294/head
woodsaj 7 years ago
parent 2365004683
commit 93fbd40e2f
  1. 4
      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)

Loading…
Cancel
Save