Skip to content

Commit da7c941

Browse files
committed
Document monitoring for Embedded GlassFish
1 parent 9ce1324 commit da7c941

File tree

1 file changed

+88
-0
lines changed

1 file changed

+88
-0
lines changed

docs/embedded-server-guide/src/main/asciidoc/embedded-server-guide.adoc

Lines changed: 88 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ The following topics are addressed here:
2020
* xref:#testing-applications-with-the-maven-plug-in-for-embedded-glassfish-server[Testing Applications with the Maven Plug-in for Embedded {productName}]
2121
* xref:#GSESG00039[Using the EJB 3.1 Embeddable API with Embedded {productName}]
2222
* xref:#changing-log-levels-in-embedded-glassfish-server[Changing Log Levels in Embedded {productName}]
23+
* xref:#monitoring-embedded-glassfish-server-with-jmx[Monitoring Embedded {productName} with JMX]
2324
* xref:#default-java-persistence-data-source-for-embedded-glassfish-server[Default Java Persistence Data Source for Embedded {productName}]
2425
* xref:#restrictions-for-embedded-glassfish-server[Restrictions for Embedded {productName}]
2526

@@ -2061,6 +2062,93 @@ command when you invoke Embedded {productName}. For example:
20612062
java -Djava.util.logging.config.file=customlogging.properties MyEmbeddedGlassFish
20622063
----
20632064

2065+
[[monitoring-embedded-glassfish-server-with-jmx]]
2066+
2067+
== Monitoring Embedded {productName} with JMX
2068+
2069+
Embedded {productName} supports monitoring through JMX MBeans, similar to regular {productName} Server. However, you must attache the flashlight agent on command line to enable monitoring functionality.
2070+
2071+
=== Prerequisites
2072+
2073+
To enable monitoring in Embedded {productName}, you need the flashlight agent JAR file:
2074+
2075+
* Download from Maven Central: `org.glassfish.main.flashlight:flashlight-agent`
2076+
* Or use from an existing {productName} installation: `glassfish/lib/monitor/flashlight-agent.jar`
2077+
2078+
=== Enabling Monitoring Modules
2079+
2080+
By default, the monitoring service and MBeans support are enabled, but no monitoring modules are active. You can enable specific monitoring modules using one of two methods:
2081+
2082+
==== Method 1: Command Line
2083+
2084+
Start Embedded {productName} with the `enable-monitoring` command:
2085+
2086+
[source]
2087+
----
2088+
java -javaagent:/path/to/flashlight-agent.jar -jar glassfish-embedded-all.jar 'enable-monitoring --modules thread-pool:http-service'
2089+
----
2090+
2091+
==== Method 2: Properties File
2092+
2093+
Create a `glassfish.properties` file in the current directory with monitoring configuration:
2094+
2095+
[source]
2096+
----
2097+
configs.config.server-config.monitoring-service.module-monitoring-levels.thread-pool=HIGH
2098+
configs.config.server-config.monitoring-service.module-monitoring-levels.http-service=HIGH
2099+
----
2100+
2101+
Then start Embedded {productName}:
2102+
2103+
[source]
2104+
----
2105+
java -javaagent:/path/to/flashlight-agent.jar -jar glassfish-embedded-all.jar
2106+
----
2107+
2108+
=== Accessing Monitoring Data
2109+
2110+
Once monitoring modules are enabled, you can access monitoring data through JMX clients such as VisualVM or JConsole.
2111+
2112+
==== Using VisualVM
2113+
2114+
1. Connect to the Embedded {productName} process in VisualVM
2115+
2. Install the MBeans extension if not already available
2116+
3. Navigate to the MBeans tab
2117+
4. Execute the `bootAMX` operation first (this is required, same as with regular {productName} Server)
2118+
5. Monitoring data will be available under the `amx` node, in nodes that end with `-mon`, such as `thread-pool-mon` or `request-mon`
2119+
2120+
==== Exposing JMX on a Specific Port
2121+
2122+
To allow remote JMX connections, you can expose the JMX server on a specific port by adding JVM system properties:
2123+
2124+
[source]
2125+
----
2126+
java -javaagent:/path/to/flashlight-agent.jar \
2127+
-Dcom.sun.management.jmxremote \
2128+
-Dcom.sun.management.jmxremote.port=8686 \
2129+
-Dcom.sun.management.jmxremote.authenticate=false \
2130+
-Dcom.sun.management.jmxremote.ssl=false \
2131+
-jar glassfish-embedded-all.jar 'enable-monitoring --modules thread-pool:http-service'
2132+
----
2133+
2134+
[WARNING]
2135+
====
2136+
Exposing JMX without authentication and SSL is not secure and should only be used in development environments. JMX MBeans include management beans that allow executing administrative operations on {productName}, which could be exploited by unauthorized users. In production environments, always enable authentication and SSL for JMX connections.
2137+
====
2138+
2139+
==== Available Monitoring Modules
2140+
2141+
Embedded {productName} supports the same monitoring modules as regular {productName} Server, including:
2142+
2143+
* `thread-pool` - Thread pool statistics
2144+
* `http-service` - HTTP service metrics
2145+
* `web-container` - Web container statistics
2146+
* `ejb-container` - EJB container metrics
2147+
* `transaction-service` - Transaction service data
2148+
* `jvm` - JVM statistics
2149+
2150+
For comprehensive information about available monitoring modules and their metrics, see xref:administration-guide.adoc#administering-the-monitoring-service[Administering the Monitoring Service] in the {productName} Administration Guide.
2151+
20642152
[[default-java-persistence-data-source-for-embedded-glassfish-server]]
20652153

20662154
== Default Java Persistence Data Source for Embedded {productName}

0 commit comments

Comments
 (0)