Skip to content

Commit 44f65bd

Browse files
committed
Application Insights Java doc improvement
1 parent 5731419 commit 44f65bd

File tree

4 files changed

+76
-31
lines changed

4 files changed

+76
-31
lines changed

.openpublishing.redirection.json

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22532,6 +22532,11 @@
2253222532
"source_path_from_root": "/articles/principles-for-ai-generated-content.md",
2253322533
"redirect_url": "https://aka.ms/ai-content-principles",
2253422534
"redirect_document_id": false
22535-
}
22535+
},
22536+
{
22537+
"source_path_from_root": "/articles/azure-monitor/app/java-standalone-arguments.md",
22538+
"redirect_url": "/azure/azure-monitor/app/get-started-supplemental",
22539+
"redirect_document_id": true
22540+
}
2253622541
]
2253722542
}

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

Lines changed: 64 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,55 @@
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+
## Containers
14+
15+
### Docker entry point
16+
17+
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:
18+
19+
```
20+
ENTRYPOINT ["java", "-javaagent:path/to/applicationinsights-agent-3.4.11.jar", "-jar", "<myapp.jar>"]
21+
```
22+
23+
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:
24+
25+
```
26+
ENTRYPOINT java -javaagent:"path/to/applicationinsights-agent-3.4.11.jar" -jar <myapp.jar>
27+
```
28+
29+
30+
### Docker file
31+
32+
A Dockerfile example:
33+
34+
```
35+
FROM ...
36+
37+
COPY target/*.jar app.jar
38+
39+
COPY agent/applicationinsights-agent-3.4.11.jar applicationinsights-agent-3.4.11.jar
40+
41+
COPY agent/applicationinsights.json applicationinsights.json
42+
43+
ENV APPLICATIONINSIGHTS_CONNECTION_STRING="CONNECTION-STRING"
44+
45+
ENTRYPOINT["java", "-javaagent:applicationinsights-agent-3.4.11.jar", "-jar", "app.jar"]
46+
```
47+
48+
### Third-party container images
49+
50+
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
51+
`JAVA_TOOL_OPTIONS=-javaagent:/path/to/applicationinsights-agent.jar`.
52+
1253

1354
## Azure App Service
1455

@@ -22,22 +63,19 @@ For more information, see [Monitoring Azure Functions with Azure Monitor Applica
2263

2364
For more information, see [Using Azure Monitor Application Insights with Spring Boot](./java-spring-boot.md).
2465

25-
## Third-party container images
26-
27-
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
28-
`JAVA_TOOL_OPTIONS=-javaagent:/path/to/applicationinsights-agent.jar`.
66+
## Java Application servers
2967

30-
## Tomcat 8 (Linux)
68+
### Tomcat 8 (Linux)
3169

32-
### Tomcat installed via apt-get or yum
70+
#### Tomcat installed via apt-get or yum
3371

3472
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:
3573

3674
```
3775
JAVA_OPTS="$JAVA_OPTS -javaagent:path/to/applicationinsights-agent-3.4.11.jar"
3876
```
3977

40-
### Tomcat installed via download and unzip
78+
#### Tomcat installed via download and unzip
4179

4280
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:
4381

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

4886
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`.
4987

50-
## Tomcat 8 (Windows)
88+
### Tomcat 8 (Windows)
5189

52-
### Run Tomcat from the command line
90+
#### Run Tomcat from the command line
5391

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

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

66104
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`.
67105

68-
### Run Tomcat as a Windows service
106+
#### Run Tomcat as a Windows service
69107

70108
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.
71109

72-
## JBoss EAP 7
110+
### JBoss EAP 7
73111

74-
### Standalone server
112+
#### Standalone server
75113

76114
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):
77115

@@ -80,7 +118,7 @@ Add `-javaagent:path/to/applicationinsights-agent-3.4.11.jar` to the existing `J
80118
...
81119
```
82120

83-
### Domain server
121+
#### Domain server
84122

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

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

126164
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.
127165

128-
## Jetty 9
166+
### Jetty 9
129167

130168
Add these lines to `start.ini`:
131169

@@ -134,7 +172,7 @@ Add these lines to `start.ini`:
134172
-javaagent:path/to/applicationinsights-agent-3.4.11.jar
135173
```
136174

137-
## Payara 5
175+
### Payara 5
138176

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

@@ -150,31 +188,32 @@ Add `-javaagent:path/to/applicationinsights-agent-3.4.11.jar` to the existing `j
150188
...
151189
```
152190

153-
## WebSphere 8
191+
### WebSphere 8
154192

155193
1. Open Management Console.
156194
1. Go to **Servers** > **WebSphere application servers** > **Application servers**. Choose the appropriate application servers and select:
157-
195+
158196
```
159197
Java and Process Management > Process definition > Java Virtual Machine
160198
```
161-
199+
162200
1. In `Generic JVM arguments`, add the following JVM argument:
163-
201+
164202
```
165203
-javaagent:path/to/applicationinsights-agent-3.4.11.jar
166204
```
167205
168206
1. Save and restart the application server.
169207
170-
## OpenLiberty 18
208+
### OpenLiberty 18
171209
172210
Create a new file `jvm.options` in the server directory (for example, `<openliberty>/usr/servers/defaultServer`), and add this line:
173211
174212
```
175213
-javaagent:path/to/applicationinsights-agent-3.4.11.jar
176214
```
177215
178-
## Others
216+
### Others
179217
180218
See your application server documentation on how to add JVM args.
219+

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)