How do you monitor Azure Event Hub consumer lag?

Viewed 2270

We have been trying monitor consumer lag on Event Hub partitions.

I have looked in the azure portal and the Event Hub Api's but so far found nothing.

Was wondering if anyone has tried this and if so could you point me in the right direction.

Thanks.

2 Answers

You can compare the Message Sequence of the current message being processed, against the last sequence number of the message received for a partition. The difference between these numbers is 'how far behind' the latest message your processing has fallen. To get the details of the last message received in a partition, you need to access a PartitionContext object.

How I've implemented this is with Azure Function and a Custom Metric in Application Insights. As a batch of messages is received, I calculate the difference between the values and write the metric, which allows me to track this in Grafana and raise alerts when required.

I wrote a medium article on how to achieve this here - https://medium.com/@dylanm_asos/azure-functions-event-hub-processing-8a3f39d2cd0f

Related