Skip to content

Commit 7058e36

Browse files
committed
feat: add Tutorial to guidle integrate with azure managed grafana for container apps
1 parent ed21f11 commit 7058e36

File tree

9 files changed

+169
-0
lines changed

9 files changed

+169
-0
lines changed

articles/container-apps/TOC.yml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -400,6 +400,9 @@
400400
- name: Create a highly available Eureka server component cluster
401401
href: java-eureka-server-highly-available.md
402402
displayName: java
403+
- name: Build a Java metrics dashboard with Azure Managed Grafana
404+
href: java-metrics-with-grafana.md
405+
displayName: java
403406
- name: Billing & quotas
404407
items:
405408
- name: Billing
Lines changed: 165 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,165 @@
1+
---
2+
title: "Tutorial: Build a Java metrics dashboard with Azure Managed Grafana"
3+
description: Learn to build a Java metrics dashboard with Azure Managed Grafana.
4+
services: container-apps
5+
author: craigshoemaker
6+
ms.service: azure-container-apps
7+
ms.custom: devx-track-extended-java
8+
ms.topic: tutorial
9+
ms.date: 12/18/2024
10+
ms.author: cshoe
11+
#customer intent: As a developer, I want to build a grafa dashboard for Java metrics exposed from Azure Container Apps
12+
---
13+
14+
# Tutorial: Build a Java metrics dashboard with Azure Managed Grafana
15+
16+
In this tutorial, you will learn how to set up a metrics dashboard using Azure Managed Grafana to monitor Java applications running in Azure Container Apps.
17+
18+
Grafana is a popular tool for centralized metrics visualization and monitoring in the observability industry. Azure Managed Grafana is a fully managed Azure service that allows you to deploy and manage Grafana dashboards with seamless Azure integration. You can use Azure Managed Grafana to visualize Java metrics exposed by Azure Container Apps or integrate Java metrics into your existing Grafana dashboards.
19+
20+
In this tutorial, you:
21+
> [!div class="checklist"]
22+
> * Create an Azure Managed Grafana instance.
23+
> * Create a Java metrics dashboard in grafana.
24+
> * Visiualize Java metrics for Azure Container Apps with grafana.
25+
26+
## Prerequisites
27+
28+
* An Azure account with an active subscription. If you don't already have one, you can [can create one for free](https://azure.microsoft.com/free/).
29+
* [Azure CLI](/cli/azure/install-azure-cli).
30+
* [A Java application deployed in Azure Container Apps](java-get-started.md).
31+
32+
## Set up the environment
33+
34+
Use the following steps to define environment variables and ensure your Azure Managed Grafana extension is up to date.
35+
36+
1. Create variables to support your grafana configuration.
37+
```bash
38+
export LOCATION=eastus
39+
export SUBSCRIPTION_ID={my-subscriprion-id}
40+
export RESOURCE_GROUP=my-grafana-resource-group
41+
export GRAFANA_INSTANCE_NAME=my-grafana-name
42+
```
43+
44+
| Variable | Description |
45+
|-------------------------|------------------------------------------------------------------------------------|
46+
| `LOCATION` | The Azure region location where you create your Azure Managed Grafana instance. |
47+
| `SUBSCRIPTION_ID` | The subscription ID which you use to create your Azure Container Apps. |
48+
| `RESOURCE_GROUP` | The Azure resource group name for your Azure Managed Grafana instance. |
49+
| `GRAFANA_INSTANCE_NAME` | The instance name for your Azure Managed Grafana instance. |
50+
51+
52+
1. Log in to Azure with the Azure CLI.
53+
54+
```azurecli
55+
az login
56+
```
57+
58+
1. Create a resource group.
59+
60+
```azurecli
61+
az group create --name $RESOURCE_GROUP --location $LOCATION
62+
```
63+
64+
1. Use the following command to ensure that you have the latest version of the Azure CLI extensions for Azure Managed Grafana:
65+
66+
```azurecli
67+
az extension add --name amg --upgrade
68+
```
69+
70+
71+
## Set up an Azure Managed Grafana instance
72+
73+
First, create an Azure Managed Grafana instance, and grant necessary role assignments.
74+
75+
1. Create an Azure Managed Grafana instance.
76+
77+
```azurecli
78+
az grafana create \
79+
--name $GRAFANA_INSTANCE_NAME \
80+
--resource-group $RESOURCE_GROUP \
81+
--location $LOCATION
82+
```
83+
84+
1. Grant the Azure Managed Grafana instance permission to read metrics from Azure Monitor. Find more about the [authentication and permissions for Azure Managed Grafana](../managed-grafana/how-to-authentication-permissions.md).
85+
86+
```azurecli
87+
GRAFA_IDDENTITY=$(az grafana show --name $GRAFANA_INSTANCE_NAME --resource-group $RESOURCE_GROUP --query "identity.principalId" --output tsv)
88+
89+
az role assignment create --assignee $GRAFA_IDDENTITY --role "Monitoring Reader" --scope /subscriptions/$SUBSCRIPTION_ID
90+
```
91+
92+
## Create an Java metrics dashboard
93+
94+
> [!IMPORTANT]
95+
> To add a new dashboard in grafana, you need to have `Grafana Admin` or `Grafana Editor`role, see [Azure Managed Grafana roles](../managed-grafana/concept-role-based-access-control.md).
96+
97+
98+
1. Assign the `Grafana Admin` role to your account on the Azure Managed Grafana resource.
99+
100+
Get the resource ID for your Azure Managed Grafana instance
101+
```azurecli
102+
GRAFANA_RESOURCE_ID=$(az grafana show --resource-group $RESOURCE_GROUP --name $GRAFANA_INSTANCE_NAME --query id --output tsv)
103+
```
104+
105+
Before running this command, replace the `<USER_OR_SERVICE_PRINCIPAL_ID>` placeholder with your user or service principal ID.
106+
107+
```azurecli
108+
az role assignment create \
109+
--assignee <USER_OR_SERVICE_PRINCIPAL_ID> \
110+
--role "Grafana Admin" \
111+
--scope $GRAFANA_RESOURCE_ID
112+
```
113+
114+
1. Download the [sample Java metric dashboard for Azure Container Apps](https://github.com/Azure-Samples/java-microservices-aca-lab/blob/main/dashboard/aca-java-metrics-dashboard.json) json file.
115+
116+
1. Get the endpoint of the Azure Managed Grafana resource.
117+
118+
```azurecli
119+
az grafana show --resource-group $RESOURCE_GROUP \
120+
--name $GRAFANA_INSTANCE_NAME \
121+
--query "properties.endpoint" \
122+
--output tsv
123+
```
124+
This command returns the URL you can use to access the Azure Managed Grafana dashboard. Open your browser with URL and login.
125+
126+
1. Go to `Dashboard` > `New` -> `Import`. Upload the above sample dashboard JSON file, and choose the default built-in `Azure Monitor` data source, then click `Import` button.
127+
128+
:::image type="content" source="media/java-metrics-with-grafana/import-java-dashboard.png" alt-text="Screenshot of importing java metric dashboard for Azure Container Apps." lightbox="media/java-metrics-with-grafana/import-java-dashboard.png":::
129+
130+
131+
## Visiualize Java metrics for Azure Container Apps with Grafana
132+
133+
1. Input your resource information in the filters for your Azure Container Apps. Now you can view all the [supported Java metrics in Azure Container Apps](java-metrics.md) within the dashboard. The sample dashboard provides live metric data, including
134+
- Container App Overview Container App Overview
135+
- JVM Memory Usage JVM Memory Usage
136+
- JVM Memory Buffer JVM Memory Buffer
137+
- JVM GC JVM GC
138+
- A detailed JVM Memory Usage Analysis detailed JVM Memory Usage Analysis
139+
140+
:::image type="content" source="media/java-metrics-with-grafana/grafana-overview.png" alt-text="Screenshot of Overview tab in grafana." lightbox="media/java-metrics-with-grafana/grafana-overview.png":::
141+
142+
:::image type="content" source="media/java-metrics-with-grafana/grafana-jvm-mem.png" alt-text="Screenshot of JVM memory tab in grafana." lightbox="media/java-metrics-with-grafana/grafana-jvm-mem.png":::
143+
144+
:::image type="content" source="media/java-metrics-with-grafana/grafana-jvm-buffer.png" alt-text="Screenshot of JVM buffer memory tab in grafana." lightbox="media/java-metrics-with-grafana/grafana-jvm-buffer.png":::
145+
146+
:::image type="content" source="media/java-metrics-with-grafana/grafana-jvm-gc.png" alt-text="Screenshot of JVM GC tab in grafana." lightbox="media/java-metrics-with-grafana/grafana-jvm-gc.png":::
147+
148+
:::image type="content" source="media/java-metrics-with-grafana/grafana-jvm-mem-analysis.png" alt-text="Screenshot of JVM memory analysis tab in grafana." lightbox="media/java-metrics-with-grafana/grafana-jvm-mem-analysis.png":::
149+
150+
151+
You can use this dashboard as a starting point to create your own customized metric visualizations and monitoring solution.
152+
153+
154+
## Clean up resources
155+
156+
The resources created in this tutorial have an effect on your Azure bill. If you aren't going to use these services long-term, run the following command to remove everything created in this tutorial.
157+
158+
```azurecli
159+
az group delete --resource-group $RESOURCE_GROUP
160+
```
161+
162+
## Related content
163+
164+
> [!div class="nextstepaction"]
165+
> [ Java metrics for Java apps in Azure Container Apps](./java-metrics.md)

articles/container-apps/java-metrics.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -130,4 +130,5 @@ You can see Java metric names on Azure Monitor, but the data sets show as empty
130130
## Next steps
131131

132132
> [!div class="nextstepaction"]
133+
> [Build a Java metrics dashboard with Azure Managed Grafana](java-metrics-with-grafana.md)
133134
> [Monitor logs with Log Analytics](log-monitoring.md)
192 KB
Loading
134 KB
Loading
248 KB
Loading
203 KB
Loading
218 KB
Loading
117 KB
Loading

0 commit comments

Comments
 (0)