My goal is to export the "ActiveMessages" metric for each queue/topic in my servicebus namespace for a dashboard. My current setup is as follows:
- Service bus (standard tier) with "Stream to an event hub" and "AllMetrics" enabled in diagnostics settings
- Azure function with event hub trigger that's listening to the configured event hub
This is what my function looks like:
public static class MetricProcessor
{
[FunctionName("MetricProcessor")]
public static void Run([EventHubTrigger("test", Connection = "AzureWebJobsEventHub")] EventData[] events, ILogger log)
{
foreach (var eventData in events)
{
var messageBody = Encoding.UTF8.GetString(eventData.Body.Array, eventData.Body.Offset, eventData.Body.Count);
log.LogInformation(messageBody);
}
}
}
The resulting message body always looks similar to the following:
{
"records": [
{
"count": 1,
"total": 1,
"minimum": 1,
"maximum": 1,
"average": 1,
"resourceId": "-",
"time": "2019-08-07T08:00:00.0000000Z",
"metricName": "IncomingRequests",
"timeGrain": "PT1M"
},
{
"count": 2,
"total": 3,
"minimum": 1,
"maximum": 2,
"average": 1.5,
"resourceId": "removed",
"time": "2019-08-07T08:01:00.0000000Z",
"metricName": "IncomingRequests",
"timeGrain": "PT1M"
},
{
"count": 2,
"total": 4,
"minimum": 2,
"maximum": 2,
"average": 2,
"resourceId": "-",
"time": "2019-08-07T08:02:00.0000000Z",
"metricName": "IncomingRequests",
"timeGrain": "PT1M"
},
{
"count": 0,
"total": 0,
"minimum": 0,
"maximum": 0,
"average": 0,
"resourceId": "-",
"time": "2019-08-07T08:00:00.0000000Z",
"metricName": "IncomingMessages",
"timeGrain": "PT1M"
},
{
"count": 0,
"total": 0,
"minimum": 0,
"maximum": 0,
"average": 0,
"resourceId": "removed",
"time": "2019-08-07T08:01:00.0000000Z",
"metricName": "IncomingMessages",
"timeGrain": "PT1M"
},
{
"count": 0,
"total": 0,
"minimum": 0,
"maximum": 0,
"average": 0,
"resourceId": "-",
"time": "2019-08-07T08:02:00.0000000Z",
"metricName": "IncomingMessages",
"timeGrain": "PT1M"
},
{
"count": 0,
"total": 0,
"minimum": 0,
"maximum": 0,
"average": 0,
"resourceId": "-",
"time": "2019-08-07T08:00:00.0000000Z",
"metricName": "OutgoingMessages",
"timeGrain": "PT1M"
},
{
"count": 0,
"total": 0,
"minimum": 0,
"maximum": 0,
"average": 0,
"resourceId": "-",
"time": "2019-08-07T08:01:00.0000000Z",
"metricName": "OutgoingMessages",
"timeGrain": "PT1M"
},
{
"count": 0,
"total": 0,
"minimum": 0,
"maximum": 0,
"average": 0,
"resourceId": "-",
"time": "2019-08-07T08:02:00.0000000Z",
"metricName": "OutgoingMessages",
"timeGrain": "PT1M"
}
]
}
Why am I only getting the "IncomingRequests", "IncomingMessages" and "OutgoingMessages" metrics?
According to this and this documentation the metrics should be available, even though it's in preview. Could someone tell me what I'm doing wrong?