Skip to content

Commit 5f1d6a6

Browse files
committed
fix
1 parent 968c98d commit 5f1d6a6

File tree

1 file changed

+60
-60
lines changed

1 file changed

+60
-60
lines changed

articles/container-apps/java-metrics-scale-with-keda.md

Lines changed: 60 additions & 60 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
---
22
title: "Tutorial: Scale a container app with Java metrics"
33
description: Scale a container app with Java metrics.
4-
services: container-apps
4+
services: azure-container-apps
55
author: craigshoemaker
66
ms.service: azure-container-apps
77
ms.custom: devx-track-extended-java
@@ -15,7 +15,7 @@ ms.author: cshoe
1515

1616
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).
1717

18-
In this tutorial, you add a custom scale rule to scale your container app with Java metrics and observe how your application scales.
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.
1919

2020
## Prerequisites
2121

@@ -41,7 +41,7 @@ Use the following steps to define environment variables and set up the environme
4141
| Variable | Description |
4242
|-------------------------|------------------------------------------------------------------------------------|
4343
| `LOCATION` | The Azure region location where you create your Azure Container Apps. |
44-
| `TENANT_ID` | Your tenant's id. |
44+
| `TENANT_ID` | Your tenant's ID. |
4545
| `SUBSCRIPTION_ID` | The subscription ID which you use to create your Azure Container Apps. |
4646
| `RESOURCE_GROUP` | The Azure resource group name for your Azure Container Apps. |
4747
| `APP_NAME` | The app name for your Azure Container Apps. |
@@ -71,7 +71,7 @@ To scale with Azure Container Apps platform metrics, you need a managed identity
7171
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).
7272
7373
```azurecli
74-
# Get the principal id for your managed identity
74+
# Get the principal ID for your managed identity
7575
PRINCIPAL_ID=$(az identity show --resource-group $RESOURCE_GROUP --name $IDENTITY_NAME --query "principalId" --output tsv)
7676
7777
az role assignment create --assignee $PRINCIPAL_ID --role "Monitoring Reader" --scope /subscriptions/$SUBSCRIPTION_ID
@@ -84,8 +84,8 @@ Here is a list of core metadata to set up the scale rule.
8484
8585
| Metadata key | Description |
8686
|------------------------------------|-------------------------------------------------------------------------------------------------------|
87-
| 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. 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. |
8989
| resourceGroupName | Name of the resource group for the Azure resource. |
9090
| resourceURI | Shortened URI to the Azure resource with format `<resourceProviderNamespace>/<resourceType>/<resourceName>`. |
9191
| metricName | Name of the metric to query. |
@@ -98,72 +98,72 @@ Here is a list of core metadata to set up the scale rule.
9898
9999
Add a scale rule with [metrics from Azure Container Apps](./metrics.md) for your application.
100100
101-
# [Azure CLI](#tab/azurecli)
101+
# [Azure CLI](#tab/azurecli)
102102
103-
```azurecli
104-
az containerapp update \
105-
--name $APP_NAME \
106-
--resource-group $RESOURCE_GROUP \
107-
--min-replicas 1 \
108-
--max-replicas 10 \
109-
--scale-rule-name scale-with-azure-monitor-metrics \
110-
--scale-rule-type azure-monitor \
111-
--scale-rule-metadata "tenantId=${TENANT_ID}" \
112-
"subscriptionId=${SUBSCRIPTION_ID}" \
113-
"resourceGroupName=${RESOURCE_GROUP}" \
114-
"resourceURI=Microsoft.App/containerapps/${APP_NAME}" \
115-
"metricName=JvmGcCount" \
116-
"metricAggregationType=Total" \
117-
"metricAggregationInterval=0:1:0" \
118-
"targetValue=30" \
119-
--scale-rule-identity $USER_ASSIGNED_IDENTITY_ID
120-
```
103+
```azurecli
104+
az containerapp update \
105+
--name $APP_NAME \
106+
--resource-group $RESOURCE_GROUP \
107+
--min-replicas 1 \
108+
--max-replicas 10 \
109+
--scale-rule-name scale-with-azure-monitor-metrics \
110+
--scale-rule-type azure-monitor \
111+
--scale-rule-metadata "tenantId=${TENANT_ID}" \
112+
"subscriptionId=${SUBSCRIPTION_ID}" \
113+
"resourceGroupName=${RESOURCE_GROUP}" \
114+
"resourceURI=Microsoft.App/containerapps/${APP_NAME}" \
115+
"metricName=JvmGcCount" \
116+
"metricAggregationType=Total" \
117+
"metricAggregationInterval=0:1:0" \
118+
"targetValue=30" \
119+
--scale-rule-identity $USER_ASSIGNED_IDENTITY_ID
120+
```
121121
122-
# [ARM Template](#tab/arm)
123-
124-
```arm
125-
{
126-
"resources": {
127-
"properties": {
128-
"template": {
129-
"scale": {
130-
"minReplicas": 1,
131-
"maxReplicas": 10,
132-
"rules": [
133-
{
134-
"name": "scale-with-azure-monitor-metrics",
135-
"custom": {
136-
"type": "azure-monitor",
137-
"metadata": {
138-
"metricAggregationInterval": "0:1:0",
139-
"metricAggregationType": "Total",
140-
"metricName": "JvmGcCount",
141-
"resourceGroupName": "<your-resource-group>",
142-
"resourceURI": "Microsoft.App/containerapps/<your-app>",
143-
"subscriptionId": "<your-subscription-id>",
144-
"targetValue": "30",
145-
"tenantId": "<your-tenant-id>"
146-
},
147-
"identity": "<your-managed-identity-id>"
148-
}
122+
# [ARM Template](#tab/arm-template)
123+
124+
```json
125+
{
126+
"resources": {
127+
"properties": {
128+
"template": {
129+
"scale": {
130+
"minReplicas": 1,
131+
"maxReplicas": 10,
132+
"rules": [
133+
{
134+
"name": "scale-with-azure-monitor-metrics",
135+
"custom": {
136+
"type": "azure-monitor",
137+
"metadata": {
138+
"metricAggregationInterval": "0:1:0",
139+
"metricAggregationType": "Total",
140+
"metricName": "JvmGcCount",
141+
"resourceGroupName": "<your-resource-group>",
142+
"resourceURI": "Microsoft.App/containerapps/<your-app>",
143+
"subscriptionId": "<your-subscription-id>",
144+
"targetValue": "30",
145+
"tenantId": "<your-tenant-id>"
146+
},
147+
"identity": "<your-managed-identity-id>"
149148
}
150-
]
151-
}
152-
}
149+
}
150+
]
151+
}
153152
}
154153
}
155154
}
156-
```
155+
}
156+
```
157157
158-
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)`.
158+
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)`.
159159
160160
> [!NOTE]
161161
> 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.
162162

163163
## View scaling in Azure portal (optional)
164164
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-
1. Go to the `Metrics` blade in the Azure Portal for your Azure Container Apps.
166-
1. Add your metric `jvm.gc.count`, with filter `Revision=<your-revision>` and Split by `Replica`.
165+
1. Go to the `Metrics` blade in the Azure portal for your Azure Container Apps.
166+
1. Add your metric `jvm.gc.count`, with filter `Revision=<your-revision>` and split by `Replica`.
167167
1. Add the metric `Replica Count`, with filter `Revision=<your-revision>`.
168168

169169
Here is a sample metric snapshot for the example scale rule.
@@ -182,7 +182,7 @@ Here is a sample metric snapshot for the example scale rule.
182182
183183
To view the KEDA scale logs, you can run the below query in `Logs`.
184184
185-
```
185+
```kusto
186186
ContainerAppSystemLogs
187187
| where RevisionName == "<your-revision>"
188188
| where EventSource == "KEDA"

0 commit comments

Comments
 (0)