Skip to content

Commit df20765

Browse files
authored
Merge pull request #273890 from craigshoemaker/aca/java-metrics
[Container Apps] New: Java metrics
2 parents 838fb11 + 4636225 commit df20765

File tree

5 files changed

+165
-32
lines changed

5 files changed

+165
-32
lines changed

articles/container-apps/TOC.yml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -323,6 +323,9 @@
323323
- name: Build environment variables
324324
href: java-build-environment-variables.md
325325
displayName: java
326+
- name: Metrics
327+
href: java-metrics.md
328+
displayName: java
326329
- name: Use Eureka Server for Spring
327330
href: java-eureka-server-usage.md
328331
- name: Use Config Server for Spring
Lines changed: 120 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,120 @@
1+
---
2+
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 |
30+
| Java | `jvm.gc.count` | Count of JVM garbage collection actions | `JvmGcCount` | n/a |
31+
| Java | `jvm.gc.duration` | Duration of JVM garbage collection actions | `JvmGcDuration` | milliseconds |
32+
| 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)
36.4 KB
Loading
30.2 KB
Loading

articles/container-apps/metrics.md

Lines changed: 42 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -5,42 +5,44 @@ services: container-apps
55
author: v-jaswel
66
ms.service: container-apps
77
ms.topic: how-to
8-
ms.date: 08/30/2022
8+
ms.date: 04/30/2024
99
ms.author: v-wellsjason
1010
---
1111

1212
# Monitor Azure Container Apps metrics
1313

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.
1515

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

1818
## Available metrics
1919

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 |
29-
|Replica Restart Count|Restarts count of container app replicas| RestartCount | n/a |
30-
|Requests|Requests processed|Requests|n/a|
31-
|Reserved Cores|Number of reserved cores for container app revisions |CoresQuotaUsed|n/a|
32-
|Resiliency Connection Timeouts |Total connection timeouts |ResiliencyConnectTimeouts |n/a|
33-
|Resiliency Ejected Hosts |Number of currently ejected hosts|ResiliencyEjectedHosts |n/a|
34-
|Resiliency Ejections Aborted |Number of ejections aborted due to the max ejection % |ResiliencyEjectionsAborted |n/a|
35-
|Resiliency Request Retries |Total request retries|ResiliencyRequestRetries|n/a|
36-
|Resiliency Request Timeouts |Total requests that timed out waiting for a response |ResiliencyRequestTimeouts|n/a|
37-
|Resiliency Requests Pending Connection Pool |Total requests pending a connection pool connection |ResiliencyRequestsPendingConnectionPool |n/a|
38-
|Total Reserved Cores |Total cores reserved for the container app |TotalCoresQuotaUsed|n/a|
20+
Container Apps provides these basic metrics.
21+
22+
| Category | Title | Description | Metric ID | Unit |
23+
|--|--|--|--|--|
24+
| Basic | CPU Usage | CPU consumed by the container app, in nano cores (1,000,000,000 nanocores = 1 core) | UsageNanoCores | `nanocores` |
25+
| Basic | Memory Working Set Bytes | Container app working set memory used in bytes | `WorkingSetBytes` | bytes |
26+
| Basic | Network In Bytes | Network received bytes | `RxBytes` | bytes |
27+
| Basic | Network Out Bytes | Network transmitted bytes | `TxBytes` | bytes |
28+
| Basic | Replica count | Number of active replicas | `Replicas` | n/a |
29+
| Basic | Replica Restart Count | Restarts count of container app replicas | `RestartCount` | n/a |
30+
| Basic | Requests | Requests processed | `Requests` | n/a |
31+
| Basic | Reserved Cores | Number of reserved cores for container app revisions | `CoresQuotaUsed` | n/a |
32+
| Basic | Resiliency Connection Timeouts | Total connection timeouts | `ResiliencyConnectTimeouts` | n/a |
33+
| Basic | Resiliency Ejected Hosts | Number of currently ejected hosts | `ResiliencyEjectedHosts` | n/a |
34+
| Basic | Resiliency Ejections Aborted | Number of ejections aborted due to the max ejection % | `ResiliencyEjectionsAborted` | n/a |
35+
| Basic | Resiliency Request Retries | Total request retries | `ResiliencyRequestRetries` | n/a |
36+
| 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 |
3939

4040
The metrics namespace is `microsoft.app/containerapps`.
4141

4242
> [!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).
4446

4547
## Metrics snapshots
4648

@@ -54,16 +56,21 @@ From this view, you can pin one or more charts to your dashboard or select a cha
5456

5557
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.
5658

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).
5860

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.
6062
:::image type="content" source="media/observability/metrics-main-page.png" alt-text="Screenshot of the metrics explorer from the container app resource page.":::
6163

6264
### Add filters
6365

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+
6570
1. Select **Add filter**.
71+
6672
1. Select a revision or replica from the **Property** list.
73+
6774
1. Select values from the **Value** list.
6875
:::image type="content" source="media/observability/metrics-add-filter.png" alt-text="Screenshot of the metrics explorer showing the chart filter options.":::
6976

@@ -72,16 +79,19 @@ Optionally, you can create filters to limit the data shown based on revisions an
7279
When your chart contains a single metric, you can choose to split the metric information by revision or replica with the exceptions:
7380

7481
* 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.
7683

7784
To split by revision or replica:
7885

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.
8491

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.":::
8595

8696
### Add scopes
8797

@@ -90,4 +100,4 @@ You can add more scopes to view metrics across multiple container apps.
90100
:::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.":::
91101

92102
> [!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

Comments
 (0)