|
| 1 | +--- |
| 2 | +title: Manage an Azure Monitor workspace (preview) |
| 3 | +description: How to create and delete Azure Monitor workspaces. |
| 4 | +author: EdB-MSFT |
| 5 | +ms.author: edbaynash |
| 6 | +ms.reviewer: poojaa |
| 7 | +ms.topic: conceptual |
| 8 | +ms.date: 01/19/2023 |
| 9 | +--- |
| 10 | + |
| 11 | +# Manage an Azure Monitor workspace |
| 12 | + |
| 13 | +This article shows you how to create and delete an Azure Monitor workspace. When you configure Azure Monitor managed service for Prometheus, you can select an existing Azure Monitor workspace or create a new one. |
| 14 | + |
| 15 | +## Create an Azure Monitor workspace |
| 16 | +### [Azure portal](#tab/azure-portal) |
| 17 | + |
| 18 | +1. Open the **Azure Monitor workspaces** menu in the Azure portal. |
| 19 | +2. Select **Create**. |
| 20 | + |
| 21 | + :::image type="content" source="media/azure-monitor-workspace-overview/view-azure-monitor-workspaces.png" lightbox="media/azure-monitor-workspace-overview/view-azure-monitor-workspaces.png" alt-text="Screenshot of Azure Monitor workspaces menu and page."::: |
| 22 | + |
| 23 | +3. On the **Create an Azure Monitor Workspace** page, select a **Subscription** and **Resource group** where the workspace should be created. |
| 24 | +4. Provide a **Name** and a **Region** for the workspace. |
| 25 | +5. Select **Review + create** to create the workspace. |
| 26 | + |
| 27 | +### [CLI](#tab/cli) |
| 28 | +Use the following command to create an Azure Monitor workspace using Azure CLI. |
| 29 | + |
| 30 | +```azurecli |
| 31 | +az resource create --resource-group <resource-group-name> --namespace microsoft.monitor --resource-type accounts --name <azure-monitor-workspace-name> --location <location> --properties {} |
| 32 | +``` |
| 33 | + |
| 34 | +### [Resource Manager](#tab/resource-manager) |
| 35 | +Use one of the following Resource Manager templates with any of the [standard deployment options](../resource-manager-samples.md#deploy-the-sample-templates) to create an Azure Monitor workspace. |
| 36 | + |
| 37 | +```json |
| 38 | +{ |
| 39 | + "$schema": "http://schema.management.azure.com/schemas/2019-04-01/deploymentTemplate.json#", |
| 40 | + "contentVersion": "1.0.0.0", |
| 41 | + "parameters": { |
| 42 | + "name": { |
| 43 | + "type": "string" |
| 44 | + }, |
| 45 | + "location": { |
| 46 | + "type": "string", |
| 47 | + "defaultValue": "" |
| 48 | + } |
| 49 | + }, |
| 50 | + "resources": [ |
| 51 | + { |
| 52 | + "type": "microsoft.monitor/accounts", |
| 53 | + "apiVersion": "2021-06-03-preview", |
| 54 | + "name": "[parameters('name')]", |
| 55 | + "location": "[if(empty(parameters('location')), resourceGroup().location, parameters('location'))]" |
| 56 | + } |
| 57 | + ] |
| 58 | +} |
| 59 | +``` |
| 60 | + |
| 61 | +```bicep |
| 62 | +@description('Specify the name of the workspace.') |
| 63 | +param workspaceName string |
| 64 | +
|
| 65 | +@description('Specify the location for the workspace.') |
| 66 | +param location string = resourceGroup().location |
| 67 | +
|
| 68 | +resource workspace 'microsoft.monitor/accounts@2021-06-03-preview' = { |
| 69 | + name: workspaceName |
| 70 | + location: location |
| 71 | +} |
| 72 | +
|
| 73 | +``` |
| 74 | + |
| 75 | +--- |
| 76 | + |
| 77 | +To connect your Azure Monitor managed service for Prometheus to your Azure Monitor workspace, see [Collect Prometheus metrics from AKS cluster](./prometheus-metrics-enable.md) |
| 78 | + |
| 79 | + |
| 80 | +## Delete an Azure Monitor workspace |
| 81 | +When you delete an Azure Monitor workspace, no soft-delete operation is performed like with a [Log Analytics workspace](../logs/delete-workspace.md). The data in the workspace is immediately deleted, and there's no recovery option. |
| 82 | + |
| 83 | + |
| 84 | +### [Azure portal](#tab/azure-portal) |
| 85 | + |
| 86 | +1. Open the **Azure Monitor workspaces** menu in the Azure portal. |
| 87 | +2. Select your workspace. |
| 88 | +4. Select **Delete**. |
| 89 | + |
| 90 | + :::image type="content" source="media/azure-monitor-workspace-overview/delete-azure-monitor-workspace.png" lightbox="media/azure-monitor-workspace-overview/delete-azure-monitor-workspace.png" alt-text="Screenshot of Azure Monitor workspaces delete button."::: |
| 91 | + |
| 92 | +### [CLI](#tab/cli) |
| 93 | +To delete an AzureMonitor workspace use [az resource delete](https://learn.microsoft.com/cli/azure/resource#az-resource-delete) |
| 94 | + |
| 95 | +For example: |
| 96 | +```azurecli |
| 97 | + az resource delete --ids /subscriptions/abcdef01-2345-6789-0abc-def012345678/resourcegroups/rg-azmon/providers/microsoft.monitor/accounts/prometheus-metrics-workspace |
| 98 | +``` |
| 99 | +or |
| 100 | + |
| 101 | +```azurecli |
| 102 | + az resource delete -g rg-azmon -n prometheus-metrics-workspace --resource-type Microsoft.Monitor/accounts |
| 103 | +``` |
| 104 | + |
| 105 | +### [Resource Manager](#tab/resource-manager) |
| 106 | +For information on deleting resources and Azure Resource Manager, see [Azure Resource Manager resource group and resource deletion](../../azure-resource-manager/management/delete-resource-group.md) |
| 107 | + |
| 108 | + |
| 109 | +--- |
| 110 | + |
| 111 | + |
| 112 | +## Link a Grafana workspace |
| 113 | +Connect an Azure Monitor workspace to an [Azure Managed Grafana](../../managed-grafana/overview.md) workspace to allow Grafana to use the Azure Monitor workspace data in a Grafana dashboard. An Azure Monitor workspace can be connected to multiple Grafana workspaces, and a Grafana workspace can be connected to multiple Azure Monitor workspaces. |
| 114 | + |
| 115 | +> [!NOTE] |
| 116 | +> When you add the Azure Monitor workspace as a data source to Grafana, it will be listed in form `Managed_Prometheus_<azure-workspace-name>`. |
| 117 | +### [Azure portal](#tab/azure-portal) |
| 118 | + |
| 119 | +1. Open the **Azure Monitor workspace** menu in the Azure portal. |
| 120 | +2. Select your workspace. |
| 121 | +3. Select **Linked Grafana workspaces**. |
| 122 | +4. Select a Grafana workspace. |
| 123 | + |
| 124 | +### [CLI](#tab/cli) |
| 125 | + |
| 126 | +Create a link between the Azure Monitor workspace and the Grafana workspace by updating the Azure Kubernetes Service cluster that you're monitoring. |
| 127 | + |
| 128 | +```azurecli |
| 129 | +az aks update --enable-azuremonitormetrics -n <cluster-name> -g <cluster-resource-group> --azure-monitor-workspace-resource-id |
| 130 | +<azure-monitor-workspace-name-resource-id> --grafana-resource-id <grafana-workspace-name-resource-id> |
| 131 | +``` |
| 132 | +If your cluster is already configured to send data to an Azure Monitor managed service for Prometheus, disable it first using the following command: |
| 133 | + |
| 134 | +```azurecli |
| 135 | +az aks update --disable-azuremonitormetrics -g <cluster-resource-group> -n <cluster-name> |
| 136 | +``` |
| 137 | + |
| 138 | +Output |
| 139 | +```JSON |
| 140 | +"azureMonitorProfile": { |
| 141 | + "metrics": { |
| 142 | + "enabled": true, |
| 143 | + "kubeStateMetrics": { |
| 144 | + "metricAnnotationsAllowList": "", |
| 145 | + "metricLabelsAllowlist": "" |
| 146 | + } |
| 147 | + } |
| 148 | +} |
| 149 | +``` |
| 150 | + |
| 151 | +### [Resource Manager](#tab/resource-manager) |
| 152 | + |
| 153 | + |
| 154 | +To set up an Azure monitor workspace as a data source for Grafana using a Resource Manager template, see [Collect Prometheus metrics from AKS cluster (preview)](prometheus-metrics-enable.md?tabs=resource-manager#enable-prometheus-metric-collection) |
| 155 | + |
| 156 | +--- |
| 157 | + |
| 158 | +If your Grafana Instance is self managed see [Use Azure Monitor managed service for Prometheus (preview) as data source for self-managed Grafana using managed system identity](./prometheus-self-managed-grafana-azure-active-directory.md) |
| 159 | + |
| 160 | + |
| 161 | + |
| 162 | + |
| 163 | + |
| 164 | + |
| 165 | + |
| 166 | +## Next steps |
| 167 | +- [Links a Grafana instance to your Azure monitor Workspace](./prometheus-metrics-enable.md#enable-prometheus-metric-collection) |
| 168 | +- Learn more about the [Azure Monitor data platform](../data-platform.md). |
| 169 | +- [Azure Monitor Workspace Overview](./azure-monitor-workspace-overview.md) |
0 commit comments