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
But I want these values to reset these properties after x units of time. how can I do that?
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 therecord-error-totalor it will always show unhealthy even if once the threshold was crossed.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?