Skip to content

Commit 5cbc93d

Browse files
Merge pull request #235007 from jeanbisutti/ai-java-improvement
Application Insights Java doc improvement
2 parents 44e576d + 9fec207 commit 5cbc93d

File tree

4 files changed

+76
-30
lines changed

4 files changed

+76
-30
lines changed

.openpublishing.redirection.json

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22547,6 +22547,11 @@
2254722547
"source_path_from_root": "/articles/principles-for-ai-generated-content.md",
2254822548
"redirect_url": "https://aka.ms/ai-content-principles",
2254922549
"redirect_document_id": false
22550-
}
22550+
},
22551+
{
22552+
"source_path_from_root": "/articles/azure-monitor/app/java-standalone-arguments.md",
22553+
"redirect_url": "/azure/azure-monitor/app/java-get-started-supplemental",
22554+
"redirect_document_id": true
22555+
}
2255122556
]
2255222557
}

articles/azure-monitor/app/java-standalone-arguments.md renamed to articles/azure-monitor/app/java-get-started-supplemental.md

Lines changed: 64 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,16 @@
11
---
2-
title: Add the JVM arg - Application Insights for Java
3-
description: Learn how to add the JVM arg that enables Application Insights for Java.
2+
title: Application Insights with containers
3+
description: This article shows you how to set-up Application Insights
44
ms.topic: conceptual
5-
ms.date: 03/31/2023
5+
ms.date: 04/06/2023
66
ms.devlang: java
77
ms.custom: devx-track-java
88
ms.reviewer: mmcc
99
---
1010

11-
# Update your JVM args: Application Insights for Java
11+
# Get Started (Supplemental)
12+
13+
In the following sections, you will find information on how to get Java auto-instrumentation for specific technical environments.
1214

1315
## Azure App Service
1416

@@ -18,26 +20,63 @@ For more information, see [Application monitoring for Azure App Service and Java
1820

1921
For more information, see [Monitoring Azure Functions with Azure Monitor Application Insights](./monitor-functions.md#distributed-tracing-for-java-applications-preview).
2022

21-
## Spring Boot
23+
## Containers
2224

23-
For more information, see [Using Azure Monitor Application Insights with Spring Boot](./java-spring-boot.md).
25+
### Docker entry point
26+
27+
If you're using the *exec* form, add the parameter `-javaagent:"path/to/applicationinsights-agent-3.4.11.jar"` to the parameter list somewhere before the `"-jar"` parameter, for example:
28+
29+
```
30+
ENTRYPOINT ["java", "-javaagent:path/to/applicationinsights-agent-3.4.11.jar", "-jar", "<myapp.jar>"]
31+
```
32+
33+
If you're using the *shell* form, add the JVM arg `-javaagent:"path/to/applicationinsights-agent-3.4.11.jar"` somewhere before `-jar`, for example:
34+
35+
```
36+
ENTRYPOINT java -javaagent:"path/to/applicationinsights-agent-3.4.11.jar" -jar <myapp.jar>
37+
```
38+
39+
40+
### Docker file
41+
42+
A Dockerfile example:
43+
44+
```
45+
FROM ...
46+
47+
COPY target/*.jar app.jar
48+
49+
COPY agent/applicationinsights-agent-3.4.11.jar applicationinsights-agent-3.4.11.jar
50+
51+
COPY agent/applicationinsights.json applicationinsights.json
2452
25-
## Third-party container images
53+
ENV APPLICATIONINSIGHTS_CONNECTION_STRING="CONNECTION-STRING"
54+
55+
ENTRYPOINT["java", "-javaagent:applicationinsights-agent-3.4.11.jar", "-jar", "app.jar"]
56+
```
57+
58+
### Third-party container images
2659

2760
If you're using a third-party container image that you can't modify, mount the Application Insights Java agent jar into the container from outside. Set the environment variable for the container
2861
`JAVA_TOOL_OPTIONS=-javaagent:/path/to/applicationinsights-agent.jar`.
2962

30-
## Tomcat 8 (Linux)
63+
## Spring Boot
3164

32-
### Tomcat installed via apt-get or yum
65+
For more information, see [Using Azure Monitor Application Insights with Spring Boot](./java-spring-boot.md).
66+
67+
## Java Application servers
68+
69+
### Tomcat 8 (Linux)
70+
71+
#### Tomcat installed via apt-get or yum
3372

3473
If you installed Tomcat via `apt-get` or `yum`, you should have a file `/etc/tomcat8/tomcat8.conf`. Add this line to the end of that file:
3574

3675
```
3776
JAVA_OPTS="$JAVA_OPTS -javaagent:path/to/applicationinsights-agent-3.4.11.jar"
3877
```
3978

40-
### Tomcat installed via download and unzip
79+
#### Tomcat installed via download and unzip
4180

4281
If you installed Tomcat via download and unzip from [https://tomcat.apache.org](https://tomcat.apache.org), you should have a file `<tomcat>/bin/catalina.sh`. Create a new file in the same directory named `<tomcat>/bin/setenv.sh` with the following content:
4382

@@ -47,9 +86,9 @@ CATALINA_OPTS="$CATALINA_OPTS -javaagent:path/to/applicationinsights-agent-3.4.1
4786

4887
If the file `<tomcat>/bin/setenv.sh` already exists, modify that file and add `-javaagent:path/to/applicationinsights-agent-3.4.11.jar` to `CATALINA_OPTS`.
4988

50-
## Tomcat 8 (Windows)
89+
### Tomcat 8 (Windows)
5190

52-
### Run Tomcat from the command line
91+
#### Run Tomcat from the command line
5392

5493
Locate the file `<tomcat>/bin/catalina.bat`. Create a new file in the same directory named `<tomcat>/bin/setenv.bat` with the following content:
5594

@@ -65,13 +104,13 @@ set "CATALINA_OPTS=%CATALINA_OPTS% -javaagent:path/to/applicationinsights-agent-
65104

66105
If the file `<tomcat>/bin/setenv.bat` already exists, modify that file and add `-javaagent:path/to/applicationinsights-agent-3.4.11.jar` to `CATALINA_OPTS`.
67106

68-
### Run Tomcat as a Windows service
107+
#### Run Tomcat as a Windows service
69108

70109
Locate the file `<tomcat>/bin/tomcat8w.exe`. Run that executable and add `-javaagent:path/to/applicationinsights-agent-3.4.11.jar` to the `Java Options` under the `Java` tab.
71110

72-
## JBoss EAP 7
111+
### JBoss EAP 7
73112

74-
### Standalone server
113+
#### Standalone server
75114

76115
Add `-javaagent:path/to/applicationinsights-agent-3.4.11.jar` to the existing `JAVA_OPTS` environment variable in the file `JBOSS_HOME/bin/standalone.conf` (Linux) or `JBOSS_HOME/bin/standalone.conf.bat` (Windows):
77116

@@ -80,7 +119,7 @@ Add `-javaagent:path/to/applicationinsights-agent-3.4.11.jar` to the existing `J
80119
...
81120
```
82121

83-
### Domain server
122+
#### Domain server
84123

85124
Add `-javaagent:path/to/applicationinsights-agent-3.4.11.jar` to the existing `jvm-options` in `JBOSS_HOME/domain/configuration/host.xml`:
86125

@@ -125,7 +164,7 @@ If you're running multiple managed servers on a single host, you'll need to add
125164

126165
The specified `applicationinsights.agent.id` value must be unique. It's used to create a subdirectory under the Application Insights directory. Each JVM process needs its own local Application Insights config and local Application Insights log file. Also, if reporting to the central collector, the `applicationinsights.properties` file is shared by the multiple managed servers, so the specified `applicationinsights.agent.id` is needed to override the `agent.id` setting in that shared file. The `applicationinsights.agent.rollup.id` can be similarly specified in the server's `system-properties` if you need to override the `agent.rollup.id` setting per managed server.
127166

128-
## Jetty 9
167+
### Jetty 9
129168

130169
Add these lines to `start.ini`:
131170

@@ -134,7 +173,7 @@ Add these lines to `start.ini`:
134173
-javaagent:path/to/applicationinsights-agent-3.4.11.jar
135174
```
136175

137-
## Payara 5
176+
### Payara 5
138177

139178
Add `-javaagent:path/to/applicationinsights-agent-3.4.11.jar` to the existing `jvm-options` in `glassfish/domains/domain1/config/domain.xml`:
140179

@@ -150,31 +189,32 @@ Add `-javaagent:path/to/applicationinsights-agent-3.4.11.jar` to the existing `j
150189
...
151190
```
152191

153-
## WebSphere 8
192+
### WebSphere 8
154193

155194
1. Open Management Console.
156195
1. Go to **Servers** > **WebSphere application servers** > **Application servers**. Choose the appropriate application servers and select:
157-
196+
158197
```
159198
Java and Process Management > Process definition > Java Virtual Machine
160199
```
161-
200+
162201
1. In `Generic JVM arguments`, add the following JVM argument:
163-
202+
164203
```
165204
-javaagent:path/to/applicationinsights-agent-3.4.11.jar
166205
```
167206
168207
1. Save and restart the application server.
169208
170-
## OpenLiberty 18
209+
### OpenLiberty 18
171210
172211
Create a new file `jvm.options` in the server directory (for example, `<openliberty>/usr/servers/defaultServer`), and add this line:
173212
174213
```
175214
-javaagent:path/to/applicationinsights-agent-3.4.11.jar
176215
```
177216
178-
## Others
217+
### Others
179218
180219
See your application server documentation on how to add JVM args.
220+

articles/azure-monitor/app/opentelemetry-enable.md

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -184,9 +184,10 @@ Java auto-instrumentation is enabled through configuration changes; no code chan
184184
Point the JVM to the jar file by adding `-javaagent:"path/to/applicationinsights-agent-3.4.11.jar"` to your application's JVM args.
185185

186186
> [!TIP]
187-
> For help with configuring your application's JVM args, see [Tips for updating your JVM args](./java-standalone-arguments.md).
188-
189-
If you develop a Spring Boot application, you can optionally replace the JVM argument by a programmatic configuration. For more information, see [Using Azure Monitor Application Insights with Spring Boot](./java-spring-boot.md).
187+
> For scenario-specific guidance, see [Get Started (Supplemental)](./java-get-started-supplemental.md).
188+
189+
> [!TIP]
190+
> If you develop a Spring Boot application, you can optionally replace the JVM argument by a programmatic configuration. For more information, see [Using Azure Monitor Application Insights with Spring Boot](./java-spring-boot.md).
190191
191192
##### [Node.js](#tab/nodejs)
192193

articles/azure-monitor/toc.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -734,6 +734,8 @@ items:
734734
href: app/java-spring-boot.md
735735
- name: Profiler
736736
href: app/java-standalone-profiler.md
737+
- name: Get started (supplemental)
738+
href: app/java-get-started-supplemental.md
737739
- name: Configuration
738740
items:
739741
- name: General
@@ -748,8 +750,6 @@ items:
748750
href: app/java-standalone-telemetry-processors.md
749751
- name: Examples
750752
href: app/java-standalone-telemetry-processors-examples.md
751-
- name: JVM arguments setup
752-
href: app/java-standalone-arguments.md
753753
- name: Upgrade from 2.x
754754
href: app/java-standalone-upgrade-from-2x.md
755755
- name: FAQ

0 commit comments

Comments
 (0)