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
title: How to enable Java metrics for Java apps in Azure Container Apps
3
+
description: Java metrics and configuration Azure Container Apps.
4
+
services: container-apps
5
+
author: craigshoemaker
6
+
ms.service: container-apps
7
+
ms.date: 05/10/2024
8
+
ms.author: cshoe
9
+
ms.topic: how-to
10
+
zone_pivot_groups: container-apps-portal-or-cli
11
+
---
12
+
13
+
# Java metrics for Java apps in Azure Container Apps
14
+
15
+
Java Virtual Machine (JVM) metrics are critical for monitoring the health and performance of your Java applications. The data collected includes insights into memory usage, garbage collection, thread count of your JVM. Use the following metrics to help ensure the health and stability of your applications.
16
+
17
+
## Collected metrics
18
+
19
+
| Category| Title | Description | Metric ID | Unit |
20
+
|---|---|---|---|---|
21
+
| Java |`jvm.memory.total.used`| Total amount of memory used by heap or nonheap |`JvmMemoryTotalUsed`| bytes |
22
+
| Java |`jvm.memory.total.committed`| Total amount of memory guaranteed to be available for heap or nonheap |`JvmMemoryTotalCommitted`| bytes |
23
+
| Java |`jvm.memory.total.limit`| Total amount of maximum obtainable memory for heap or nonheap |`JvmMemoryTotalLimit`| bytes |
24
+
| Java |`jvm.memory.used`| Amount of memory used by each pool |`JvmMemoryUsed`| bytes |
25
+
| Java |`jvm.memory.committed`| Amount of memory guaranteed to be available for each pool |`JvmMemoryCommitted`| bytes |
26
+
| Java |`jvm.memory.limit`| Amount of maximum obtainable memory for each pool |`JvmMemoryLimit`| bytes |
27
+
| Java |`jvm.buffer.memory.usage`| Amount of memory used by buffers, such as direct memory |`JvmBufferMemoryUsage`| bytes |
28
+
| Java |`jvm.buffer.memory.limit`| Amount of total memory capacity of buffers |`JvmBufferMemoryLimit`| bytes |
29
+
| Java |`jvm.buffer.count`| Number of buffers in the memory pool |`JvmBufferCount`| n/a |
| Java |`jvm.thread.count`| Number of executing platform threads |`JvmThreadCount`| n/a |
33
+
34
+
## Configuration
35
+
36
+
::: zone pivot="azure-portal"
37
+
38
+
To make the collection of Java metrics available to your app, you have to create your container app with some specific settings.
39
+
40
+
In the *Create* window, if you select for *Deployment source* the **Container image** option, then you have access to stack-specific features.
41
+
42
+
Under the *Development stack-specific features* and for the *Development stack*, select **Java**.
43
+
44
+
:::image type="content" source="media/java-metrics/azure-container-apps-java-metrics-development-stack.png" alt-text="Screenshot of the Azure portal where you can select Java-specific features for your container app." lightbox="media/java-metrics/azure-container-apps-java-metrics-development-stack.png":::
45
+
46
+
Once you select the Java development stack, the *Customize Java features for your app* window appears. Next to the *Java features* label, select **JVM core metrics**.
47
+
48
+
::: zone-end
49
+
50
+
::: zone pivot="azure-cli"
51
+
52
+
There are two CLI options related to the app runtime and Java metrics:
53
+
54
+
| Option | Description |
55
+
|---|---|
56
+
|`--runtime`| The runtime of the container app. Supported values are `generic` and `java`. |
57
+
|`--enable-java-metrics`| A boolean option that enables or disables Java metrics for the app. Only applicable for Java runtime. |
58
+
59
+
> [!NOTE]
60
+
> The `--enable-java-metrics=<true|false>` parameter implicitly sets `--runtime=java`. The `--runtime=generic` parameter resets all java runtime info.
61
+
62
+
### Enable Java metrics
63
+
64
+
You can enable Java metrics either via the `create` or `update` commands.
65
+
66
+
# [create](#tab/create)
67
+
68
+
```azurecli
69
+
az containerapp create \
70
+
--name <CONTAINER_APP_NAME> \
71
+
--resource-group <RESOURCE_GROUP> \
72
+
--image <CONTAINER_IMAGE_LOCATION> \
73
+
--enable-java-metrics=true
74
+
```
75
+
76
+
# [update](#tab/update)
77
+
78
+
```azurecli
79
+
az containerapp update \
80
+
--name <CONTAINER_APP_NAME> \
81
+
--resource-group <RESOURCE_GROUP> \
82
+
--enable-java-metrics=true
83
+
```
84
+
85
+
### Disable Java metrics
86
+
87
+
You can disable Java metrics using the `up` command.
88
+
89
+
```azurecli
90
+
az containerapp up \
91
+
--name <CONTAINER_APP_NAME> \
92
+
--resource-group <RESOURCE_GROUP> \
93
+
--enable-java-metrics=false
94
+
```
95
+
96
+
> [!NOTE]
97
+
> The container app restarts when you update java metrics flag.
98
+
99
+
::: zone-end
100
+
101
+
## View Java Metrics
102
+
103
+
Use the following steps to view metrics visualizations for your container app.
104
+
105
+
1. Go to the Azure portal.
106
+
107
+
1. Go to your container app.
108
+
109
+
1. Under the *Monitoring* section, select **Metrics**.
110
+
111
+
From there, you're presented with a chart that plots the metrics you're tracking in your application.
112
+
113
+
:::image type="content" source="media/java-metrics/azure-container-apps-java-metrics-visualization.png" alt-text="Screenshot of Java metrics visualization." lightbox="media/java-metrics/azure-container-apps-java-metrics-visualization.png":::
114
+
115
+
You can see Java metric names on Azure Monitor, but the data sets report as empty unless you use the `--enable-java-metrics` parameter to enable Java metrics.
116
+
117
+
## Next steps
118
+
119
+
> [!div class="nextstepaction"]
120
+
> [Monitor logs with Log Analytics](log-monitoring.md)
Copy file name to clipboardExpand all lines: articles/container-apps/metrics.md
+42-32Lines changed: 42 additions & 32 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -5,42 +5,44 @@ services: container-apps
5
5
author: v-jaswel
6
6
ms.service: container-apps
7
7
ms.topic: how-to
8
-
ms.date: 08/30/2022
8
+
ms.date: 04/30/2024
9
9
ms.author: v-wellsjason
10
10
---
11
11
12
12
# Monitor Azure Container Apps metrics
13
13
14
-
Azure Monitor collects metric data from your container app at regular intervals to help you gain insights into the performance and health of your container app.
14
+
Azure Monitor collects metric data from your container app at regular intervals to help you gain insights into the performance and health of your container app.
15
15
16
16
The metrics explorer in the Azure portal allows you to visualize the data. You can also retrieve raw metric data through the [Azure CLI](/cli/azure/monitor/metrics) and Azure [PowerShell cmdlets](/powershell/module/az.monitor/get-azmetric).
17
17
18
18
## Available metrics
19
19
20
-
Container Apps provides these metrics.
21
-
22
-
|Title | Description | Metric ID |Unit |
23
-
|---------|---------|---------|---------|
24
-
| CPU Usage | CPU consumed by the container app, in nano cores (1,000,000,000 nanocores = 1 core) | UsageNanoCores|nanocores|
25
-
|Memory Working Set Bytes |Container app working set memory used in bytes|WorkingSetBytes|bytes|
26
-
|Network In Bytes|Network received bytes|RxBytes|bytes|
27
-
|Network Out Bytes|Network transmitted bytes|TxBytes|bytes|
28
-
|Replica count|Number of active replicas|Replicas | n/a |
| Basic |Resiliency Request Timeouts |Total requests that timed out waiting for a response |`ResiliencyRequestTimeouts`|n/a|
37
+
| Basic |Resiliency Requests Pending Connection Pool |Total requests pending a connection pool connection |`ResiliencyRequestsPendingConnectionPool`|n/a|
38
+
| Basic |Total Reserved Cores |Total cores reserved for the container app |`TotalCoresQuotaUsed`|n/a|
39
39
40
40
The metrics namespace is `microsoft.app/containerapps`.
41
41
42
42
> [!NOTE]
43
-
> Replica Restart Count is the aggregate restart count over the specified time range, not the number of restarts that occurred at a point in time.
43
+
> Replica restart count is the aggregate restart count over the specified time range, not the number of restarts that occurred at a point in time.
44
+
45
+
More runtime specific metrics are available, [Java metrics](./java-metrics.md).
44
46
45
47
## Metrics snapshots
46
48
@@ -54,16 +56,21 @@ From this view, you can pin one or more charts to your dashboard or select a cha
54
56
55
57
The Azure Monitor metrics explorer lets you create charts from metric data to help you analyze your container app's resource and network usage over time. You can pin charts to a dashboard or in a shared workbook.
56
58
57
-
1. Open the metrics explorer in the Azure portal by selecting **Metrics** from the sidebar menu on your container app's page. To learn more about metrics explorer, see [Analyze metrics with Azure Monitor metrics explorer](../azure-monitor/essentials/analyze-metrics.md).
59
+
1. Open the metrics explorer in the Azure portal by selecting **Metrics** from the sidebar menu on your container app's page. To learn more about metrics explorer, see [Analyze metrics with Azure Monitor metrics explorer](../azure-monitor/essentials/analyze-metrics.md).
58
60
59
-
1. Create a chart by selecting **Metric**. You can modify the chart by changing aggregation, adding more metrics, changing time ranges and intervals, adding filters, and applying splitting.
61
+
1. Create a chart by selecting **Metric**. You can modify the chart by changing aggregation, adding more metrics, changing time ranges and intervals, adding filters, and applying splitting.
60
62
:::image type="content" source="media/observability/metrics-main-page.png" alt-text="Screenshot of the metrics explorer from the container app resource page.":::
61
63
62
64
### Add filters
63
65
64
-
Optionally, you can create filters to limit the data shown based on revisions and replicas. To create a filter:
66
+
Optionally, you can create filters to limit the data shown based on revisions and replicas.
67
+
68
+
To create a filter:
69
+
65
70
1. Select **Add filter**.
71
+
66
72
1. Select a revision or replica from the **Property** list.
73
+
67
74
1. Select values from the **Value** list.
68
75
:::image type="content" source="media/observability/metrics-add-filter.png" alt-text="Screenshot of the metrics explorer showing the chart filter options.":::
69
76
@@ -72,16 +79,19 @@ Optionally, you can create filters to limit the data shown based on revisions an
72
79
When your chart contains a single metric, you can choose to split the metric information by revision or replica with the exceptions:
73
80
74
81
* The *Replica count* metric can only split by revision.
75
-
* The *Requests* metric can also be split by status code and status code category.
82
+
* The *Requests* metric can also be split on the status code and status code category.
76
83
77
84
To split by revision or replica:
78
85
79
-
1. Select **Apply splitting**
80
-
1. Select **Revision** or **Replica** from the **Values** drop-down list.
81
-
1.You can set the limit of the number of revisions or replicas to display in the chart. The default is 10.
82
-
1. You can set Sort order to **Ascending** or **Descending**. The default is **Descending**.
83
-
:::image type="content" source="media/observability/metrics-alert-split-by-dimension.png" alt-text="Screenshot of metrics splitting options.":::
86
+
1. Select **Apply splitting**.
87
+
88
+
1.From the **Values** drop-down list, select **Revision**or **Replica**.
89
+
90
+
1. You can set the limit of the number of revisions or replicas to display in the chart. The default value is 10.
84
91
92
+
1. You can set sort order to **Ascending** or **Descending**. The default value is *Descending*.
93
+
94
+
:::image type="content" source="media/observability/metrics-alert-split-by-dimension.png" alt-text="Screenshot of metrics splitting options.":::
85
95
86
96
### Add scopes
87
97
@@ -90,4 +100,4 @@ You can add more scopes to view metrics across multiple container apps.
90
100
:::image type="content" source="media/observability/metrics-across-apps.png" alt-text="Screenshot of the metrics explorer that shows a chart with metrics for multiple container apps.":::
91
101
92
102
> [!div class="nextstepaction"]
93
-
> [Set up alerts in Azure Container Apps](alerts.md)
103
+
> [Set up alerts in Azure Container Apps](alerts.md)
0 commit comments