-
Notifications
You must be signed in to change notification settings - Fork 72
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
grafana monitoring workspace cross subscription registration
* grafana and monitoring workspaces can now existin different subscriptions * grafana setup extracted to dedicated template (still part of the global pipeline though) * cleanup of unused resources (monitoring msi)
- Loading branch information
Showing
19 changed files
with
158 additions
and
143 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
5 changes: 5 additions & 0 deletions
5
dev-infrastructure/configurations/global-grafana.tmpl.bicepparam
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
using '../templates/global-grafana.bicep' | ||
|
||
param globalMSIName = '{{ .global.globalMSIName }}' | ||
param grafanaName = '{{ .monitoring.grafanaName }}' | ||
param grafanaAdminGroupPrincipalId = '{{ .monitoring.grafanaAdminGroupPrincipalId }}' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,4 @@ | ||
using '../modules/metrics/metrics.bicep' | ||
|
||
param monitorName = '{{ .monitoring.workspaceName }}' | ||
param grafanaName = '{{ .monitoring.grafanaName }}' | ||
param msiName = '{{ .monitoring.msiName }}' | ||
param globalResourceGroup = '{{ .global.rg }}' | ||
param grafanaResourceId = '__grafanaResourceId__' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,25 +1,18 @@ | ||
// this module is only used in dev | ||
@description('Metrics global resource group name') | ||
param globalResourceGroup string | ||
|
||
@description('Metrics global MSI name') | ||
param msiName string | ||
@description('The grafana instance to integrate with') | ||
param grafanaResourceId string | ||
|
||
@description('Metrics regional monitor name') | ||
param monitorName string | ||
|
||
@description('Metrics global Grafana name') | ||
param grafanaName string | ||
|
||
module monitor 'monitor.bicep' = { | ||
name: 'monitor' | ||
params: { | ||
globalResourceGroup: globalResourceGroup | ||
msiName: msiName | ||
grafanaResourceId: grafanaResourceId | ||
monitorName: monitorName | ||
grafanaName: grafanaName | ||
} | ||
} | ||
|
||
output msiId string = monitor.outputs.msiId | ||
output monitorId string = monitor.outputs.monitorId | ||
output monitorPrometheusQueryEndpoint string = monitor.outputs.monitorPrometheusQueryEndpoint |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
@description('The global msi name') | ||
param globalMSIName string | ||
|
||
@description('Metrics global Grafana name') | ||
param grafanaName string | ||
|
||
@description('The admin group principal ID to manage Grafana') | ||
param grafanaAdminGroupPrincipalId string | ||
|
||
resource ev2MSI 'Microsoft.ManagedIdentity/userAssignedIdentities@2023-01-31' existing = { | ||
name: globalMSIName | ||
} | ||
|
||
// Azure Managed Grafana Workspace Contributor: Can manage Azure Managed Grafana resources, without providing access to the workspaces themselves. | ||
// https://learn.microsoft.com/en-us/azure/role-based-access-control/built-in-roles/monitor#azure-managed-grafana-workspace-contributor | ||
var grafanaContributor = '5c2d7e57-b7c2-4d8a-be4f-82afa42c6e95' | ||
|
||
// Grafana Admin: Perform all Grafana operations, including the ability to manage data sources, create dashboards, and manage role assignments within Grafana. | ||
// https://learn.microsoft.com/en-us/azure/role-based-access-control/built-in-roles/monitor#grafana-admin | ||
var grafanaAdminRole = '22926164-76b3-42b3-bc55-97df8dab3e41' | ||
|
||
var grafanaAdminGroup = { | ||
principalId: grafanaAdminGroupPrincipalId | ||
principalType: 'group' | ||
} | ||
|
||
resource grafana 'Microsoft.Dashboard/grafana@2023-09-01' = { | ||
name: grafanaName | ||
location: resourceGroup().location | ||
sku: { | ||
name: 'Standard' | ||
} | ||
identity: { | ||
type: 'SystemAssigned' | ||
} | ||
} | ||
|
||
resource contributorRole 'Microsoft.Authorization/roleAssignments@2022-04-01' = { | ||
name: guid(grafana.id, ev2MSI.id, grafanaContributor) | ||
scope: grafana | ||
properties: { | ||
principalId: ev2MSI.properties.principalId | ||
principalType: 'ServicePrincipal' | ||
roleDefinitionId: subscriptionResourceId('Microsoft.Authorization/roleDefinitions', grafanaContributor) | ||
} | ||
} | ||
|
||
resource adminRole 'Microsoft.Authorization/roleAssignments@2022-04-01' = { | ||
name: guid(grafana.id, grafanaAdminGroup.principalId, grafanaAdminRole) | ||
scope: grafana | ||
properties: { | ||
principalId: grafanaAdminGroup.principalId | ||
principalType: grafanaAdminGroup.principalType | ||
roleDefinitionId: subscriptionResourceId('Microsoft.Authorization/roleDefinitions', grafanaAdminRole) | ||
} | ||
} | ||
|
||
output grafanaId string = grafana.id |
Oops, something went wrong.