Use Kafka Prod metrics such that metrics are calculated for a window of time

Viewed 130

I wish to use Kafka Producer metrics:

kafkaSender.doOnProducer(Producer::metrics).subscribe(x ->
        {
          for (Entry<MetricName, ? extends Metric> entry : x.entrySet()) {
            System.out.println(entry.getKey().name() + " : " + entry.getValue().metricValue());
          }
        }
    );

to get the records that could not be published and found these 2 useful metrics in apache kafka documentation:

record-error-rate The average per-second number of record sends that resulted in errors

record-error-total The total number of record sends that resulted in errors

  1. But I want these values to reset these properties after x units of time. how can I do that?

  2. Basically I am looking to identify health of my publisher and if record-error-total > threshold, we will say it is not healthy...but we need to reset the record-error-total or it will always show unhealthy even if once the threshold was crossed.

  3. record-error-rate - does this look at (record sends that resulted in errors/time) from the start of application or is there any time window maintained internally?

0 Answers
Related