diff --git a/app/vmalert/remotewrite/client.go b/app/vmalert/remotewrite/client.go index 1ddec30e2..c6f535cc6 100644 --- a/app/vmalert/remotewrite/client.go +++ b/app/vmalert/remotewrite/client.go @@ -148,11 +148,6 @@ func (c *Client) Close() error { return nil } -// CloseAndReport closes the client and report dropped rows -func (c *Client) CloseAndReport() (int64, error) { - return int64(droppedRows.Get()), c.Close() -} - func (c *Client) run(ctx context.Context) { ticker := time.NewTicker(c.flushInterval) wr := &prompbmarshal.WriteRequest{} @@ -217,6 +212,9 @@ var ( }) ) +// GetDroppedRows returns value of droppedRows metric +func GetDroppedRows() int64 { return int64(droppedRows.Get()) } + // flush is a blocking function that marshals WriteRequest and sends // it to remote-write endpoint. Flush performs limited amount of retries // if request fails. diff --git a/app/vmalert/remotewrite/debug_client.go b/app/vmalert/remotewrite/debug_client.go index 52e0237d8..17443c731 100644 --- a/app/vmalert/remotewrite/debug_client.go +++ b/app/vmalert/remotewrite/debug_client.go @@ -60,11 +60,6 @@ func (c *DebugClient) Close() error { return nil } -// CloseAndReport closes the client and reports dropped rows -func (c *DebugClient) CloseAndReport() (int64, error) { - return 0, c.Close() -} - func (c *DebugClient) send(data []byte) error { b := snappy.Encode(nil, data) r := bytes.NewReader(b) diff --git a/app/vmalert/remotewrite/remotewrite.go b/app/vmalert/remotewrite/remotewrite.go index 957acd804..27d505e48 100644 --- a/app/vmalert/remotewrite/remotewrite.go +++ b/app/vmalert/remotewrite/remotewrite.go @@ -10,6 +10,4 @@ type RWClient interface { Push(s prompbmarshal.TimeSeries) error // Close stops the client. Client can't be reused after Close call. Close() error - // CloseAndReport stops the client and reports dropped rows - CloseAndReport() (int64, error) } diff --git a/app/vmalert/replay.go b/app/vmalert/replay.go index 0679fd415..0d3a4a4d9 100644 --- a/app/vmalert/replay.go +++ b/app/vmalert/replay.go @@ -69,9 +69,12 @@ func replay(groupsCfg []config.Group, qb datasource.QuerierBuilder, rw remotewri total += ng.Replay(tFrom, tTo, rw, *replayMaxDatapoints, *replayRuleRetryAttempts, *replayRulesDelay, *disableProgressBar) } logger.Infof("replay evaluation finished, generated %d samples", total) - droppedRows, err := rw.CloseAndReport() - if err == nil && droppedRows != 0 { + if rw != nil { + return rw.Close() + } + droppedRows := remotewrite.GetDroppedRows() + if droppedRows > 0 { return fmt.Errorf("failed to push all generated samples to remote write url, dropped %d samples out of %d", droppedRows, total) } - return err + return nil }