|
| 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: 04/30/2024 |
| 8 | +ms.author: cshoe |
| 9 | +zone_pivot_groups: container-apps-portal-or-cli |
| 10 | +--- |
| 11 | + |
| 12 | +# Java metrics for Java apps in Azure Container Apps |
| 13 | + |
| 14 | +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. |
| 15 | + |
| 16 | +## Collected metrics |
| 17 | + |
| 18 | +| Category| Title | Description | Metric ID | Unit | |
| 19 | +|---|---|---|---|---| |
| 20 | +| Java | `jvm.memory.total.used` | Total amount of memory used by heap or nonheap | `JvmMemoryTotalUsed` | bytes | |
| 21 | +| Java | `jvm.memory.total.committed` | Total amount of memory guaranteed to be available for heap or nonheap | `JvmMemoryTotalCommitted` | bytes | |
| 22 | +| Java | `jvm.memory.total.limit` | Total amount of maximum obtainable memory for heap or nonheap | `JvmMemoryTotalLimit` | bytes | |
| 23 | +| Java | `jvm.memory.used` | Amount of memory used by each pool | `JvmMemoryUsed` | bytes | |
| 24 | +| Java | `jvm.memory.committed` | Amount of memory guaranteed to be available for each pool | `JvmMemoryCommitted` | bytes | |
| 25 | +| Java | `jvm.memory.limit` | Amount of maximum obtainable memory for each pool | `JvmMemoryLimit` | bytes | |
| 26 | +| Java | `jvm.buffer.memory.usage` | Amount of memory used by buffers, such as direct memory | `JvmBufferMemoryUsage` | bytes | |
| 27 | +| Java | `jvm.buffer.memory.limit` | Amount of total memory capacity of buffers | `JvmBufferMemoryLimit` | bytes | |
| 28 | +| Java | `jvm.buffer.count` | Number of buffers in the memory pool | `JvmBufferCount` | n/a | |
| 29 | +| Java | `jvm.gc.count` | Count of JVM garbage collection actions | `JvmGcCount` | n/a | |
| 30 | +| Java | `jvm.gc.duration` | Duration of JVM garbage collection actions | `JvmGcDuration` | milliseconds | |
| 31 | +| Java | `jvm.thread.count` | Number of executing platform threads | `JvmThreadCount` | n/a | |
| 32 | + |
| 33 | +## Configuration |
| 34 | + |
| 35 | +::: zone pivot="azure-portal" |
| 36 | + |
| 37 | +TODO: screenshots here |
| 38 | + |
| 39 | +::: zone-end |
| 40 | + |
| 41 | +::: zone pivot="azure-cli" |
| 42 | + |
| 43 | +There are two CLI options related to the app runtime and Java metrics: |
| 44 | + |
| 45 | +| Option | Description | |
| 46 | +|---|---| |
| 47 | +| `--runtime` | The runtime of the container app. Supported values are `generic` and `java`. | |
| 48 | +| `--enable-java-metrics` | A boolean option that enables or disables Java metrics for the app. Only applicable for Java runtime. | |
| 49 | + |
| 50 | +> [!NOTE] |
| 51 | +> * The `--enable-java-metrics=<true|false>` parameter implicitly sets `--runtime=java`. The `--runtime=generic` parameter resets all java runtime info. |
| 52 | +
|
| 53 | +### Enable Java metrics |
| 54 | + |
| 55 | +You can enable Java metrics either via the `create` or `update` commands. |
| 56 | + |
| 57 | +# [create](#tab/create) |
| 58 | + |
| 59 | +```azurecli |
| 60 | +az containerapp create \ |
| 61 | + --name <CONTAINER_APP_NAME> \ |
| 62 | + --resource-group <RESOURCE_GROUP> \ |
| 63 | + --image <CONTAINER_IMAGE_LOCATION> \ |
| 64 | + --enable-java-metrics=true |
| 65 | +``` |
| 66 | + |
| 67 | +# [update](#tab/update) |
| 68 | + |
| 69 | +```azurecli |
| 70 | +az containerapp update \ |
| 71 | + --name <CONTAINER_APP_NAME> \ |
| 72 | + --resource-group <RESOURCE_GROUP> \ |
| 73 | + --enable-java-metrics=true |
| 74 | +``` |
| 75 | + |
| 76 | +### Disable Java metrics |
| 77 | + |
| 78 | +You can disable Java metrics using the `up` command. |
| 79 | + |
| 80 | +```azurecli |
| 81 | +az containerapp up \ |
| 82 | + --name <CONTAINER_APP_NAME> \ |
| 83 | + --resource-group <RESOURCE_GROUP> \ |
| 84 | + --enable-java-metrics=false |
| 85 | +``` |
| 86 | + |
| 87 | +> [!NOTE] |
| 88 | +> The container app restarts when you update java metrics flag. |
| 89 | +
|
| 90 | +::: zone-end |
| 91 | + |
| 92 | +## View Java Metrics |
| 93 | + |
| 94 | +TODO: some sample screenshots for java metrics |
| 95 | + |
| 96 | +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. |
| 97 | + |
| 98 | +## Next steps |
| 99 | + |
| 100 | +> [!div class="nextstepaction"] |
| 101 | +> [Monitor logs with Log Analytics](log-monitoring.md) |
0 commit comments