Skip to content

Commit c085415

Browse files
committed
Add CLI commands
1 parent f8659b8 commit c085415

File tree

1 file changed

+90
-2
lines changed

1 file changed

+90
-2
lines changed

articles/managed-grafana/create-grafana-dashboard.md

Lines changed: 90 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,10 @@ To quickly create a dashboard, import a dashboard template from the Grafana Labs
2626

2727
1. From the Grafana Labs website, browse through [Grafana dashboards templates](https://grafana.com/grafana/dashboards/?category=azure) and select a dashboard to import.
2828
1. Select **Copy ID to clipboard**.
29-
1. In the Azure portal, open your Azure Managed Grafana workspace and select the **Endpoint** URL.
29+
30+
### [Portal](#tab/azure-portal)
31+
32+
3. In the Azure portal, open your Azure Managed Grafana workspace and select the **Endpoint** URL.
3033
1. In your Grafana endpoint, go to **Dashboards > Import**.
3134
1. On the **Import** page, under **Import via grafana.com**, paste the Grafana dashboard ID copied earlier, and select **Load**.
3235

@@ -37,10 +40,23 @@ To quickly create a dashboard, import a dashboard template from the Grafana Labs
3740
1. A new dashboard is displayed.
3841
1. Review the visualizations displayed and edit the dashboard if necessary.
3942

43+
### [Azure CLI](#tab/azure-cli)
44+
45+
1. Open a CLI and run the `az login` command.
46+
1. Run the [az grafana dashboard import](/cli/azure/grafana/dashboard#az-grafana-update)command and replace the placeholders `<AMG-name>`, `<AMG-resource-group>`, and `<dashboard-id>` with the name of the Azure Managed Grafana instance, its resource group, and the dashboard ID you copied earlier.
47+
48+
```azurecli
49+
az grafana dashboard import --name <AMG-name> --resource-group <AMG-resource-group> --definition <dashboard-id>
50+
```
51+
52+
---
53+
4054
## Create a new Grafana dashboard
4155

4256
If none of the pre-configured dashboards listed on the Grafana Labs website fit your needs, create a new dashboard.
4357

58+
### [Portal](#tab/azure-portal)
59+
4460
1. In the Azure portal, open your Azure Managed Grafana workspace and select the **Endpoint** URL.
4561
1. In your Grafana endpoint, go to **Dashboards > New Dashboard**.
4662
1. Select one of the following options:
@@ -50,9 +66,37 @@ If none of the pre-configured dashboards listed on the Grafana Labs website fit
5066

5167
:::image type="content" source="media/dashboard/from-scratch.png" alt-text="Screenshot of the Grafana instance. Create a new dashboard.":::
5268

69+
### [Azure CLI](#tab/azure-cli)
70+
71+
Run the [az grafana dashboard create](/cli/azure/grafana/dashboard#az-grafana-dashboard-create) command and replace the placeholders `<AMG-name>`, `<AMG-resource-group>`, `<title>`, and `<definition>` with the name of the Azure Managed Grafana instance, its resource group, a title and a definition for the new dashboard. The definition consists of a dashboard model in JSON string, a path or URL to a file with such content.
72+
73+
```azurecli
74+
az grafana dashboard create --name <AMG-name> --resource-group <AMG-resource-group> --title <title> --definition <definition>
75+
```
76+
77+
For example:
78+
79+
```azurecli
80+
az grafana dashboard create --name myGrafana --resource-group myResourceGroup --title "My dashboard" --folder folder1 --definition '{
81+
"dashboard": {
82+
"annotations": {
83+
...
84+
},
85+
"panels": {
86+
...
87+
}
88+
},
89+
"message": "Create a new test dashboard"
90+
}'
91+
```
92+
93+
---
94+
5395
## Duplicate a Grafana dashboard
5496

55-
To copy a Grafana dashboard.
97+
### [Portal](#tab/azure-portal)
98+
99+
To copy a Grafana dashboard:
56100

57101
1. Open an existing dashboard in your Grafana instance
58102
1. Select **Dashboard settings**
@@ -61,8 +105,42 @@ To copy a Grafana dashboard.
61105

62106
:::image type="content" source="media\dashboard\copy-dashboard.png" alt-text="Screenshot of the Grafana instance. Duplicate a dashboard.":::
63107

108+
### [Azure CLI](#tab/azure-cli)
109+
110+
1. Run the [az grafana dashboard show](/cli/azure/grafana/dashboard#az-grafana-dashboard-show) command to show the definition of the dashboard you want to duplicate, and copy the output.
111+
112+
```azurecli
113+
az grafana dashboard show --name <AMG-name> --dashboard <dashboard-UID>
114+
```
115+
116+
1. Run the [az grafana dashboard create](/cli/azure/grafana/dashboard#az-grafana-dashboard-create) command and replace the placeholders `<AMG-name>`, `<AMG-resource-group>`, `<title>`, and `<dashboard-id>` with your own information. Replace `<definition>` with the output you copied in the previous step, and remove the `uid`and `id`.
117+
118+
```azurecli
119+
az grafana dashboard create --name <AMG-name> --resource-group <AMG-resource-group> --title <title>--definition <definition>
120+
```
121+
122+
For example:
123+
124+
```azurecli
125+
az grafana dashboard create --name myGrafana --resource-group myResourceGroup --title "My dashboard" --folder folder1 --definition '{
126+
"dashboard": {
127+
"annotations": {
128+
...
129+
},
130+
"panels": {
131+
...
132+
}
133+
},
134+
"message": "Create a new test dashboard"
135+
}'
136+
```
137+
138+
---
139+
64140
## Edit a dashboard panel
65141

142+
### [Portal](#tab/azure-portal)
143+
66144
To update a Grafana panel, follow the steps below.
67145

68146
1. Review the panel to check if you're satisfied with it or want to make some edits.
@@ -90,6 +168,16 @@ To update a Grafana panel, follow the steps below.
90168

91169
1. On the right hand side, select the **Panel options** icon to review and update various panel options.
92170

171+
## [Azure CLI](#tab/azure-cli)
172+
173+
Run the [az grafana dashboard update](/cli/azure/grafana/dashboard#az-grafana-dashboard-update) command and update the Grafana dashboard definition.
174+
175+
```azurecli
176+
az grafana dashboard update --name <AMG-name> --resource-group <AMG-resource-group> --definition <definition>
177+
```
178+
179+
---
180+
93181
## Next steps
94182

95183
In this how-to guide, you learned how to create a Grafana dashboard. To learn how to manage your data sources, go to:

0 commit comments

Comments
 (0)