I’m trying to deploy a dashboard that displays a couple of metrics for a Service Bus Queue in the Azure Portal using Bicep. Creating the tiles itself works fine, but I’m struggling with displaying the metrics for a filtered resource. Currently, my Bicep file looks like this:
resource dashboard 'Microsoft.Portal/dashboards@2020-09-01-preview' = {
name: dashboardName
location: location
tags: tags
properties: {
lenses: [
{
order: 0
parts: [
{
position: {
x: 0
y: 1
rowSpan: 3
colSpan: 5
}
metadata: {
inputs: [
{
name: 'options'
isOptional: true
}
{
name: 'sharedTimeRange'
isOptional: true
}
]
type: 'Extension/HubsExtension/PartType/MonitorChartPart'
settings: {
content: {
options: {
chart: {
filters: [
{
property: 'EntityName'
operator: 'Equals'
values: [
serviceBusQueueName
]
}
]
metrics: [
{
resourceMetadata: {
id: serviceBusNamespace
}
name: 'activeMessages'
aggregationType: 0
namespace: 'Microsoft.ServiceBus/namespaces'
metricVisualization: {
displayName: 'Active Messages'
}
}
{
resourceMetadata: {
id: serviceBusNamespace
}
name: 'deadLetteredMessages'
aggregationType: 0
namespace: 'Microsoft.ServiceBus/namespaces'
metricVisualization: {
displayName: 'Dead-Lettered Messages'
}
}
{
resourceMetadata: {
id: serviceBusNamespace
}
name: 'completeMessage'
aggregationType: 0
namespace: 'Microsoft.ServiceBus/namespaces'
metricVisualization: {
displayName: 'Completed Messages'
}
}
]
title: chartTitle
titleKind: 2
visualization: {
chartType: 2
legendVisualization: {
isVisible: true
position: 2
hideSubtitle: false
}
axisVisualization: {
x: {
isVisible: true
axisType: 2
}
y: {
isVisible: true
axisType: 1
}
}
disablePinning: true
}
}
}
}
}
}
}
]
}
]
metadata: {
model: {
timeRange: {
value: {
relative: {
duration: 24
timeUnit: 1
}
}
type: 'MsPortalFx.Composition.Configuration.ValueTypes.TimeRange'
}
filterLocale: {
value: 'en-us'
}
filters: {
value: {
MsPortalFx_TimeRange: {
model: {
format: 'local'
granularity: 'auto'
relative: '24h'
}
displayCache: {
name: 'Local Time'
value: 'Past 24 hours'
}
}
}
}
}
}
}
}
The chart is created but displays the metrics for the entire Service Bus instead of the specific Queue. How can I add the filter to the Bicep so that only the metrics for a specific Service Bus Queue are displayed?
2
Answers
It seems you’re missing on providing the correct resource ID in place of namespace. As per your bicep configuration should include the queue’s path within the Service Bus namespace.
Bicep configuration:
Deployment Succeeded:
This configuration will display the metrics of the specific Service Bus Queue by mentioning the
resourceId
of the queue. This makes sure that the metrics showed were specific to the queue rather than the entire Service Bus namespace.Reference:
https://learn.microsoft.com/en-us/azure/azure-portal/azure-portal-dashboards
https://learn.microsoft.com/en-us/azure/service-bus-messaging/monitor-service-bus-reference
Just created a dashboard and checked the configuration using
az portal dashboard
cli command (see documentation).The
filters
property needs to be inside afilterCollection
property and you need to specify the servicebus namespace resource id rather than the name