上一秒有多少消息通过 Azure 服务总线?

How many messages have passed through Azure service bus during the last second?

我想以编程方式知道在最后一分钟内有多少消息来自队列 posted/retrieved。 Azure 门户允许查看此内容:

我想在我的应用程序中获取相同的数据。最好在最后一天获得此信息,但从现在起也将有效。我知道如何从 MessageCountDetails class 获取当前消息数,但这不是一回事。

I want to programmatically know how many messages were posted/retrieved from the queue during the last minute. Azure portal allows viewing this

您可以使用 Monitor Service API 来做到这一点。 新的 .NETSTD 客户端不提供与 .NETFX MessageCountDetails 等效的功能,因此我汇总了 sample 如何使用 Monitor Service API 检索指标,您可以将其用作起点.

在监控服务 API 发布之前,您可以使用 Service Bus Entity Metrics REST APIs。您不会获得每秒计数 - 最小分辨率为 5 分钟,但您可以获得过去的一些值,而不仅仅是最后一个间隔。另请注意,在该值可用之前存在一些延迟(分钟)。

Azure Service Bus Entity Metrics .NET APIs 展示了如何从 C# 获取这些指标。

Azure Monitor provides monitoring of resources based on metrics, logs, etc. Using Microsoft.Azure.Management.Monitor.Fluent 库,可以检索此处提到的资源的指标。