tommed
tommed

Reputation: 1561

Get the item count for an Azure EventHub

So I am using EventHubs for data pipeline queuing, but in order to get the benefit of buffered ingestion, I need to know how many items are in a partition at any one time. Depending on the consumer group and partition id this can give massive insight into which receivers need to be scaled or aren't performing as expected.

I am aware you can create alerts based on the number of messages, but what I really want is the ability to request the current item count of a given Namespace, EventHub, Consumer Group or Partition (whatever is available) from within my C# code.

I can see that you can easily get the queue size in bytes using the .NET ServiceBus API, but I can't see any way of getting the item count?

Upvotes: 3

Views: 3401

Answers (2)

Chris Lowndes
Chris Lowndes

Reputation: 21

If the events streaming into your EventHub have a timestamp, your code can simply monitor the difference between event time and current time. This will vary proportional to 'queue length', as it is a measure of the latency caused by outgoing processing being at a lower rate than incoming events.

Upvotes: 0

Alex Belotserkovskiy
Alex Belotserkovskiy

Reputation: 4062

According to the Event Hubs REST API, there is no way to get the amount of messages in the Event Hub for an exact moment. You may try to play with the Incoming Messages amount and Outgoing Messages amount or get the size of the messages in the Hub, if you know at least approx. the size (and divide by that).

Upvotes: 2

Related Questions