Skip to content

Commit

Permalink
feat(new): Added Azure.Grafana.Version (#2883)
Browse files Browse the repository at this point in the history
* feat(new): Added Azure.Grafana.Version

* fix: Removed file

* Bump docs

---------

Co-authored-by: Bernie White <[email protected]>
  • Loading branch information
BenjaminEngeset and BernieWhite authored May 23, 2024
1 parent fb7cdd1 commit bbe08c4
Show file tree
Hide file tree
Showing 5 changed files with 278 additions and 4 deletions.
9 changes: 5 additions & 4 deletions docs/CHANGELOG-v1.md
Original file line number Diff line number Diff line change
Expand Up @@ -29,14 +29,15 @@ See [upgrade notes][1] for helpful information when upgrading from previous vers

## Unreleased

What's changed since pre-release v1.37.0-B0009:

- New rules:
- Application Gateway:
- Check that WAF v2 doesn't use legacy WAF configuration by @BenjaminEngeset.
[#2877](https://github.com/Azure/PSRule.Rules.Azure/issues/2877)

What's changed since pre-release v1.37.0-B0009:

- New rules:
- Azure Managed Grafana:
- Check that Azure Managed Grafana workspaces uses Grafana version 10 by @BenjaminEngeset.
[#2878](https://github.com/Azure/PSRule.Rules.Azure/issues/2878)
- Cosmos DB:
- Check that database accounts have local authentication disabled by @BenjaminEngeset.
[#2846](https://github.com/Azure/PSRule.Rules.Azure/issues/2846)
Expand Down
87 changes: 87 additions & 0 deletions docs/en/rules/Azure.Grafana.Version.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,87 @@
---
severity: Important
pillar: Reliability
category: RE:04 Target metrics
resource: Azure Managed Grafana
online version: https://azure.github.io/PSRule.Rules.Azure/en/rules/Azure.Grafana.Version/
---

# Upgrade Grafana version

## SYNOPSIS

Grafana workspaces should be on Grafana version 10.

## DESCRIPTION

Support for Grafana version 9 within Azure Managed Grafana is deprecated and will retire on 31 August 2024.
To avoid support disruptions, upgrade to Grafana version 10.

## RECOMMENDATION

Upgrade to Grafana version 10 for Azure Managed Grafana workspaces to avoid support disruptions.

## EXAMPLES

### Configure with Azure template

To deploy Azure Managed Grafana workspaces that pass this rule:

- Set the `properties.grafanaMajorVersion` property to `10`.

For example:

```json
{
"type": "Microsoft.Dashboard/grafana",
"apiVersion": "2023-09-01",
"name": "[parameters('name')]",
"location": "[parameters('location')]",
"sku": {
"name": "Standard"
},
"identity": {
"type": "SystemAssigned"
},
"properties": {
"grafanaMajorVersion": "10"
}
}
```

### Configure with Bicep

To deploy Azure Managed Grafana workspaces that pass this rule:

- Set the `properties.grafanaMajorVersion` property to `10`.

For example:

```bicep
resource grafana 'Microsoft.Dashboard/grafana@2023-09-01' = {
name: name
location: location
sku: {
name: 'Standard'
}
identity: {
type: 'SystemAssigned'
}
properties: {
grafanaMajorVersion: '10'
}
}
```

### Configure with Azure CLI

```bash
az grafana update --name <azure-managed-grafana-workspace> --major-version 10
```

## LINKS

- [RE:04 Target metrics](https://learn.microsoft.com/azure/well-architected/reliability/metrics)
- [Update to using Grafana version 10 for Azure Managed Grafana](https://azure.microsoft.com/updates/action-recommended-update-to-using-grafana-version-10-for-azure-managed-grafana)
- [Upgrade to Grafana 10](https://learn.microsoft.com/azure/managed-grafana/how-to-upgrade-grafana-10)
- [Azure resource deployment](https://learn.microsoft.com/azure/templates/microsoft.dashboard/grafana)
29 changes: 29 additions & 0 deletions src/PSRule.Rules.Azure/rules/Azure.Grafana.Rule.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
# Copyright (c) Microsoft Corporation.
# Licensed under the MIT License.

#
# Validation rules for Azure Managed Grafana
#

#region Rules

---
# Synopsis: Grafana workspaces should be on Grafana version 10.
apiVersion: github.com/microsoft/PSRule/v1
kind: Rule
metadata:
name: Azure.Grafana.Version
ref: AZR-000424
tags:
release: GA
ruleSet: 2024_06
Azure.WAF/pillar: Reliability
spec:
type:
- Microsoft.Dashboard/grafana
condition:
field: properties.grafanaMajorVersion
greaterOrEquals: 10
convert: true

#endregion Rules
55 changes: 55 additions & 0 deletions tests/PSRule.Rules.Azure.Tests/Azure.Grafana.Tests.ps1
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
# Copyright (c) Microsoft Corporation.
# Licensed under the MIT License.

#
# Unit tests for Azure Managed Grafana rules
#

[CmdletBinding()]
param ()

BeforeAll {
# Setup error handling
$ErrorActionPreference = 'Stop';
Set-StrictMode -Version latest;

if ($Env:SYSTEM_DEBUG -eq 'true') {
$VerbosePreference = 'Continue';
}

# Setup tests paths
$rootPath = $PWD;
Import-Module (Join-Path -Path $rootPath -ChildPath out/modules/PSRule.Rules.Azure) -Force;
$here = (Resolve-Path $PSScriptRoot).Path;
}

Describe 'Azure.Grafana' -Tag 'Grafana' {
Context 'Conditions' {
BeforeAll {
$invokeParams = @{
Baseline = 'Azure.All'
Module = 'PSRule.Rules.Azure'
WarningAction = 'Ignore'
ErrorAction = 'Stop'
}
$dataPath = Join-Path -Path $here -ChildPath 'Resources.Grafana.json';
$result = Invoke-PSRule @invokeParams -InputPath $dataPath;
}

It 'Azure.Grafana.Version' {
$filteredResult = $result | Where-Object { $_.RuleName -eq 'Azure.Grafana.Version' };

# Fail
$ruleResult = @($filteredResult | Where-Object { $_.Outcome -eq 'Fail' });
$ruleResult.Length | Should -Be 1;
$ruleResult.TargetName | Should -Be 'grafana-a';

$ruleResult[0].Reason | Should -Be "Path properties.grafanaMajorVersion: The value '9' is not >= 10.";

# Pass
$ruleResult = @($filteredResult | Where-Object { $_.Outcome -eq 'Pass' });
$ruleResult.Length | Should -Be 1;
$ruleResult.TargetName | Should -Be 'grafana-b';
}
}
}
102 changes: 102 additions & 0 deletions tests/PSRule.Rules.Azure.Tests/Resources.Grafana.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,102 @@
[
{
"type": "Microsoft.Dashboard/grafana",
"apiVersion": "2023-09-01",
"ResourceId": "/subscriptions/00000000-0000-0000-0000-000000000000/resourcegroups/test-rg/providers/Microsoft.Dashboard/grafana/grafana-a",
"name": "grafana-a",
"location": "westus",
"tags": {
"application": "grafana"
},
"sku": {
"name": "Standard"
},
"identity": {
"type": "SystemAssigned"
},
"properties": {
"apiKey": "string",
"autoGeneratedDomainNameLabelScope": "TenantReuse",
"deterministicOutboundIP": "string",
"enterpriseConfigurations": {
"marketplaceAutoRenew": "string",
"marketplacePlanId": "string"
},
"grafanaConfigurations": {
"smtp": {
"enabled": "bool",
"fromAddress": "string",
"fromName": "string",
"host": "string",
"password": "string",
"skipVerify": "bool",
"startTLSPolicy": "string",
"user": "string"
}
},
"grafanaIntegrations": {
"azureMonitorWorkspaceIntegrations": [
{
"azureMonitorWorkspaceResourceId": "00000000-0000-0000-0000-000000000000"
}
]
},
"grafanaMajorVersion": "9",
"grafanaPlugins": {
"{customized property}": {}
},
"publicNetworkAccess": "Enabled",
"zoneRedundancy": null
}
},
{
"type": "Microsoft.Dashboard/grafana",
"apiVersion": "2023-09-01",
"ResourceId": "/subscriptions/00000000-0000-0000-0000-000000000000/resourcegroups/test-rg/providers/Microsoft.Dashboard/grafana/grafana-b",
"name": "grafana-b",
"location": "westeurope",
"tags": {
"application": "grafana"
},
"sku": {
"name": "Standard"
},
"identity": {
"type": "SystemAssigned"
},
"properties": {
"apiKey": "string",
"autoGeneratedDomainNameLabelScope": "TenantReuse",
"deterministicOutboundIP": "string",
"enterpriseConfigurations": {
"marketplaceAutoRenew": "string",
"marketplacePlanId": "string"
},
"grafanaConfigurations": {
"smtp": {
"enabled": "bool",
"fromAddress": "string",
"fromName": "string",
"host": "string",
"password": "string",
"skipVerify": "bool",
"startTLSPolicy": "string",
"user": "string"
}
},
"grafanaIntegrations": {
"azureMonitorWorkspaceIntegrations": [
{
"azureMonitorWorkspaceResourceId": "00000000-0000-0000-0000-000000000000"
}
]
},
"grafanaMajorVersion": "10",
"grafanaPlugins": {
"{customized property}": {}
},
"publicNetworkAccess": "Enabled",
"zoneRedundancy": null
}
}
]

0 comments on commit bbe08c4

Please sign in to comment.