Skip to content

Commit be82c19

Browse files
add article draft
1 parent 2932200 commit be82c19

File tree

2 files changed

+122
-0
lines changed

2 files changed

+122
-0
lines changed
Lines changed: 122 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,122 @@
1+
---
2+
title: "Tutorial: Observability of managed Java components"
3+
description: Learn how to retrieve logs of managed Java components.
4+
services: container-apps
5+
author: craigshoemaker
6+
ms.service: container-apps
7+
ms.custom: devx-track-extended-java
8+
ms.topic: conceptual
9+
ms.date: 04/30/2024
10+
ms.author: cshoe
11+
zone_pivot_groups: container-apps-portal-or-cli
12+
---
13+
14+
# Tutorial: Observability of managed Java components
15+
16+
Java components include built-in observability features that could give you a holistic view of Java component health throughout its lifecycle.
17+
18+
## Prerequisites
19+
20+
The following prerequisites are required for this tutorial.
21+
22+
| Resource | Description |
23+
|---|---|
24+
| Azure Log Analytics | To use the built-in observability features of managed Java components, ensure you set up your Azure Log Analytics for logging and monitoring in a managed environment as outlined in the document, either using **Log Analytics** or **Azure Monitor**. [Log storage and monitoring options in Azure Container Apps](log-options.md) |
25+
| Java component | Make sure to create at least one Java component in your environment, such as [Eureka](java-eureka-server.md) and [config server](java-config-server.md). |
26+
27+
## Query log data
28+
29+
Log Analytics is a tool in the Azure portal used to view and analyze log data. Using Log Analytics, you can write Kusto queries to retrieve, sort, filter, and visualize the log data. These visualizations help you spot trends and identify issues with your application. You can work interactively with the query results or use them with other features such as alerts, dashboards, and workbooks.
30+
31+
::: zone pivot="azure-portal"
32+
33+
To query Java component logs in Azure, begin by accessing your Azure Log Analytics workspace associated with your environment. From there, proceed by selecting **Logs** from the sidebar.
34+
35+
Focus your query on the Java component logs by utilizing the **ContainerAppSystemlogs_CL** table, which is found under the **CustomLogs** category in **Tables** tab.
36+
37+
:::image type="content" source="media/java-component-logs/java-component-logs.png" alt-text="Screenshot of the Log Analytics Java component logs.":::
38+
39+
The following Kusto query displays the log entries of Eureka Server for Spring component logs.
40+
41+
```kusto
42+
ContainerAppSystemLogs_CL
43+
| where ComponentType_s == 'SpringCloudEureka'
44+
| project Time=TimeGenerated, Type=ComponentType_s, Component=ComponentName_s, Message=Log_s
45+
| take 100
46+
```
47+
48+
::: zone-end
49+
50+
::: zone pivot="azure-cli"
51+
52+
Java component logs can be queried using the [Azure CLI](/cli/azure/monitor/log-analytics).
53+
54+
The following example Azure CLI queries output a table containing log records for the Eureka Server for Spring component. The `project` operator's parameters specify the table columns. The `$WORKSPACE_CUSTOMER_ID` variable contains the GUID of the Log Analytics workspace.
55+
56+
# [Bash](#tab/bash)
57+
58+
```azurecli
59+
az monitor log-analytics query --workspace $WORKSPACE_CUSTOMER_ID --analytics-query "ContainerAppSystemLogs_CL | where ComponentType_s == 'SpringCloudEureka' | project Time=TimeGenerated, Type=ComponentType_s, Component=ComponentName_s, Message=Log_s | take 5" --out table
60+
```
61+
62+
# [PowerShell](#tab/powershell)
63+
64+
```powershell
65+
$queryResults = Invoke-AzOperationalInsightsQuery -WorkspaceId $WORKSPACE_CUSTOMER_ID -Query "ContainerAppSystemLogs_CL | where ComponentType_s == 'SpringCloudEureka' | project Time=TimeGenerated, Type=ComponentType_s, Component=ComponentName_s, Message=Log_s | take 5"
66+
$queryResults.Results
67+
```
68+
69+
---
70+
71+
::: zone-end
72+
73+
## Query Java Component Log with Azure monitor
74+
75+
Azure Monitor is a comprehensive monitoring solution for collecting, analyzing, and responding to monitoring data from your cloud and on-premises environments. Azure Monitor can direct logs to one or more destinations, here we take Log Analytics workspace being a primary example of such a destination.
76+
77+
::: zone pivot="azure-portal"
78+
79+
To query Java components in Azure using Azure Monitor, with Log Analytics workspace as the destination, you have two options: navigate directly to your Log Analytics workspace or access the logs through the Managed Environment's **Log** panel as follows.
80+
81+
Focus your query on the Java component logs by utilizing the **ContainerAppSystemLogs** table, which is found under the **Container Apps** category in **Tables** tab.
82+
83+
:::image type="content" source="media/java-component-logs/java-component-logs.png" alt-text="Screenshot of the Log Analytics Java component logs portal location.":::
84+
85+
The following Kusto query displays the log entries of Eureka Server for Spring component logs.
86+
87+
```kusto
88+
ContainerAppSystemLogs
89+
| where ComponentType == "SpringCloudEureka"
90+
| project Time=TimeGenerated, Type=ComponentType, Component=ComponentName, Message=Log
91+
| take 100
92+
```
93+
94+
::: zone-end
95+
96+
::: zone pivot="azure-cli"
97+
98+
Java component logs can be queried using the [Azure CLI](/cli/azure/monitor/log-analytics).
99+
100+
The following example Azure CLI queries output a table containing log records for the Eureka Server for Spring component. The `project` operator's parameters specify the table columns. The `$WORKSPACE_CUSTOMER_ID` variable contains the GUID of the Log Analytics workspace.
101+
102+
# [Bash](#tab/bash)
103+
104+
```azurecli
105+
az monitor log-analytics query --workspace $WORKSPACE_CUSTOMER_ID --analytics-query "ContainerAppSystemLogs | where ComponentType == 'SpringCloudEureka' | project Time=TimeGenerated, Type=ComponentType, Component=ComponentName, Message=Log | take 5" --out table
106+
```
107+
108+
# [PowerShell](#tab/powershell)
109+
110+
```powershell
111+
$queryResults = Invoke-AzOperationalInsightsQuery -WorkspaceId $WORKSPACE_CUSTOMER_ID -Query "ContainerAppSystemLogs | where ComponentType == 'SpringCloudEureka' | project Time=TimeGenerated, Type=ComponentType, Component=ComponentName, Message=Log | take 5"
112+
$queryResults.Results
113+
```
114+
115+
---
116+
117+
::: zone-end
118+
119+
## Next steps
120+
121+
> [!div class="nextstepaction"]
122+
> [Log storage and monitoring options in Azure Container Apps](log-options.md)
94.3 KB
Loading

0 commit comments

Comments
 (0)