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
+12-10Lines changed: 12 additions & 10 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -15,7 +15,7 @@ ms.author: cshoe
15
15
16
16
Azure Container Apps manages automatic horizontal scaling through a set of declarative scaling rules. You can create your own scale rules with [customized event sources](./scale-app.md#custom).
17
17
18
-
In this tutorial, you will add a custom scale rule to scale your container app with Java metrics and observe how your application scales.
18
+
In this tutorial, you add a custom scale rule to scale your container app with Java metrics and observe how your application scales.
19
19
20
20
## Prerequisites
21
21
@@ -47,7 +47,7 @@ Use the following steps to define environment variables and set up the environme
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.|
49
49
50
-
1. Log in to Azure with the Azure CLI.
50
+
1. Sign in to Azure with the Azure CLI.
51
51
52
52
```azurecli
53
53
az login
@@ -62,13 +62,13 @@ Use the following steps to define environment variables and set up the environme
62
62
## Set up a managed identity for your Azure Container Apps
63
63
To scale with Azure Container Apps platform metrics, you need a managed identity to access metrics from Azure Monitor.
64
64
65
-
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 below CLI command to set the identity ID.
65
+
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 to your managed identity to read data from Azure Monitor. You can find more details about the RBAC for Azure Monitor in [Built-in Role Monitoring Reader](../role-based-access-control/built-in-roles/monitor.md#monitoring-reader).
71
+
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 [Built-in Role Monitoring Reader](../role-based-access-control/built-in-roles/monitor.md#monitoring-reader).
72
72
73
73
```azurecli
74
74
# Get the principal ID for your managed identity
@@ -80,12 +80,12 @@ To scale with Azure Container Apps platform metrics, you need a managed identity
80
80
## Add a scale rule with Azure Monitor metrics
81
81
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.
82
82
83
-
Here is a list of core metadata to set up the scale rule.
83
+
Here's a list of core metadata to set up the scale rule.
| tenantId | ID of the tenant that contains the Azure resource. This is used for authentication. |
88
-
| subscriptionId | ID of the Azure subscription that contains the Azure resource. This is used for determining the full resource URI. |
87
+
| tenantId | ID of the tenant that contains the Azure resource. |
88
+
| subscriptionId | ID of the Azure subscription that contains the Azure resource. |
89
89
| resourceGroupName | Name of the resource group for the Azure resource. |
90
90
| resourceURI | Shortened URI to the Azure resource with format `<resourceProviderNamespace>/<resourceType>/<resourceName>`. |
91
91
| metricName | Name of the metric to query. |
@@ -155,6 +155,8 @@ az containerapp update \
155
155
}
156
156
```
157
157
158
+
159
+
158
160
This command adds a scale rule to your container app with the name `scale-with-azure-monitor-metrics`, and the scale type is set to `azure-monitor`. It uses the managed identity with resource ID `USER_ASSIGNED_IDENTITY_ID` to authenticate with Azure Monitor and query metrics for your container app. In the example, KEDA queries the metric `JvmGcCount`, and aggregates the metric values within 1 minute with aggregation type`Total`. The target value is set to `30`, which means KEDA calculates the `desiredReplicas` using `ceil(AggregatedMetricValue(JvmGcCount)/30)`.
159
161
160
162
> [!NOTE]
@@ -166,11 +168,11 @@ Once your new revision is ready, [send requests](./tutorial-scaling.md#send-requ
166
168
1. Add your metric `jvm.gc.count`, with filter `Revision=<your-revision>` and split by `Replica`.
167
169
1. Add the metric `Replica Count`, with filter `Revision=<your-revision>`.
168
170
169
-
Here is a sample metric snapshot for the example scale rule.
171
+
Here's a sample metric snapshot for the example scale rule.
170
172
171
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":::
172
174
173
-
1. Initially, there is 1 replica (the `minReplicas`) for the app.
175
+
1. Initially, there's one replica (the `minReplicas`) for the app.
174
176
1. A spike in requests causes the replica to experience frequent JVM garbage collection (GC).
175
177
1. KEDA observes the aggregated metric value for `jvm.gc.count` is increased to 140 and calculates desiredReplicas as `ceil(140/30)` = 5.
176
178
1. KEDA scales out the container app's replica count to 5.
@@ -180,7 +182,7 @@ Here is a sample metric snapshot for the example scale rule.
180
182
181
183
## Scale Log
182
184
183
-
To view the KEDA scale logs, you can run the below query in `Logs`.
185
+
To view the KEDA scale logs, you can run the query in`Logs`.
0 commit comments