You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: articles/container-apps/java-metrics-scale-with-keda.md
+19-19Lines changed: 19 additions & 19 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -6,7 +6,7 @@ author: craigshoemaker
6
6
ms.service: azure-container-apps
7
7
ms.custom: devx-track-extended-java
8
8
ms.topic: tutorial
9
-
ms.date: 12/23/2024
9
+
ms.date: 03/25/2026
10
10
ms.author: cshoe
11
11
#customer intent: As a developer, I want to set up auto scale using Java metrics exposed from Azure Container Apps
12
12
---
@@ -19,9 +19,9 @@ In this tutorial, you add a custom scale rule to scale your container app with J
19
19
20
20
## Prerequisites
21
21
22
-
* An Azure account with an active subscription. If you don't already have one, you can [create one for free](https://azure.microsoft.com/pricing/purchase-options/azure-account?cid=msft_learn).
23
-
*[Azure CLI](/cli/azure/install-azure-cli).
24
-
*[A Java application deployed in Azure Container Apps](java-get-started.md).
22
+
- An Azure account with an active subscription. If you don't already have one, you can [create one for free](https://azure.microsoft.com/pricing/purchase-options/azure-account?cid=msft_learn).
23
+
-[Azure CLI](/cli/azure/install-azure-cli).
24
+
-[A Java application deployed in Azure Container Apps](java-get-started.md).
25
25
26
26
## Set up the environment
27
27
@@ -42,7 +42,7 @@ Use the following steps to define environment variables and set up the environme
|`LOCATION`| The Azure region location where you create your Azure Container Apps. |
44
44
|`TENANT_ID`| Your tenant's ID. |
45
-
| `SUBSCRIPTION_ID` | The subscription ID which you use to create your Azure Container Apps. |
45
+
| `SUBSCRIPTION_ID` | The subscription ID, which you use to create your Azure Container Apps. |
46
46
| `RESOURCE_GROUP` | The Azure resource group name for your Azure Container Apps. |
47
47
| `APP_NAME` | The app name for your Azure Container Apps. |
48
48
| `IDENTITY_NAME` | The name for your managed identity, which is assigned to your Azure Container Apps.|
@@ -54,25 +54,27 @@ Use the following steps to define environment variables and set up the environme
54
54
```
55
55
56
56
## Set up a managed identity for your Azure Container Apps
57
+
57
58
To scale with Azure Container Apps platform metrics, you need a managed identity to access metrics from Azure Monitor.
58
59
59
60
1. Create a user-assigned identity and assign it to your Azure Container Apps. You can follow the doc [add a user-assigned identity](./managed-identity.md#add-a-user-assigned-identity). After you create the identity, run the CLI command to set the identity ID.
2. Grant the `Monitoring Reader` role for your managed identity to read data from Azure Monitor. You can find more details about the roles for Azure Monitor in [Azure built-in roles for Monitor](../role-based-access-control/built-in-roles/monitor.md#monitoring-reader).
az role assignment create --assignee $PRINCIPAL_ID --role "Monitoring Reader" --scope /subscriptions/$SUBSCRIPTION_ID
72
-
```
72
+
az role assignment create --assignee $PRINCIPAL_ID --role "Monitoring Reader" --scope /subscriptions/$SUBSCRIPTION_ID
73
+
```
73
74
74
75
## Add a scale rule with Azure Monitor metrics
75
-
To scale with Azure Monitor metrics, you can refer to [Azure Monitor KEDA scaler](https://keda.sh/docs/2.16/scalers/azure-monitor/) to define your Container Apps scale rule.
76
+
77
+
To scale with Azure Monitor metrics, you can refer to the [Azure Monitor Kubernetes Event-driven Autoscaling (KEDA) scaler](https://keda.sh/docs/2.16/scalers/azure-monitor/) to define your Container Apps scale rule.
76
78
77
79
Here's a list of core metadata to set up the scale rule.
78
80
@@ -85,11 +87,9 @@ Here's a list of core metadata to set up the scale rule.
85
87
| metricName | Name of the metric to query. |
86
88
| metricAggregationType | Aggregation method of the Azure Monitor metric. Options include Average, Total, Maximum. |
87
89
| metricFilter | Name of the filter to be more specific by using dimensions listed in the official documentation. (Optional) |
88
-
| metricAggregationInterval | Collection time of the metric in format "hh:mm:ss" (Default: "0:5:0", Optional) |
90
+
| metricAggregationInterval | Collection time of the metric inthe format `hh:mm:ss` (Default: `0:5:0`, Optional) |
89
91
| targetValue | Target value to trigger scaling actions. (This value can be a float) |
90
92
91
-
92
-
93
93
Add a scale rule with [Azure Monitor metrics for Azure Container Apps](./metrics.md) for your application.
94
94
95
95
### [Azure CLI](#tab/azurecli)
@@ -161,19 +161,19 @@ This command adds a scale rule to your container app with the name `scale-with-a
161
161
> The metric `JvmGcCount` is only used as an example. You can use any metric from Azure Monitor. Before setting up the scale rule, view the metrics in the Azure portal to determine the appropriate metric, aggregation interval, and target value based on your application's requirements. Additionally, consider using the built-in [HTTP/TCP scale rules](./scale-app.md#http), which can meet most common scaling scenarios, before opting for a custom metric.
162
162
163
163
## View scaling in Azure portal (optional)
164
+
164
165
Once your new revision is ready, [send requests](./tutorial-scaling.md#send-requests) to your container app to trigger auto scale with your Java metrics.
165
166
1. Go to the `Metrics` blade in the Azure portal for your Azure Container Apps.
166
167
1. Add a chart, use the metric `jvm.gc.count`, with filter `Revision=<your-revision>`, aggregation using `Sum`, and split by `Replica`. You can see the `JvmGcCount` metric value for each replica in this chat.
167
168
1. Add a chart, use the metric `jvm.gc.count`, with filter `Revision=<your-revision>` and aggregation using `Sum`. You can see the total aggregated `JvmGcCount` metric value for the revision in this chat.
168
169
1. Add a chart, use the metric `Replica Count`, with filter `Revision=<your-revision>` and aggregation using `Max`. You can see the replica count for the revision in this chat.
169
170
170
-
171
171
Here's a sample metric snapshot for the example scale rule.
172
172
173
173
:::image type="content" source="media/java-metrics-keda/keda-auto-scale-java-gc-portal.png" alt-text="Screenshot of KEDA scale with JVM metrics." lightbox="media/java-metrics-keda/keda-auto-scale-java-gc-portal.png":::
174
174
175
175
1. Initially, there's one replica (the `minReplicas`) for the app.
176
-
1. A spike in requests causes the Java app to experience frequent JVM garbage collection (GC).
176
+
1. A spike in requests causes the Java app to experience frequent Java Virtual Machine (JVM) garbage collection (GC).
177
177
1. KEDA observes the aggregated metric value for `jvm.gc.count` is increased to `256`, and calculates the `desiredReplicas` value as `ceil(256/30)=9`.
178
178
1. KEDA scales out the container app's replica count to 9.
179
179
1. The http traffic is distributed across more replicas, reducing the average GC count.
0 commit comments