Wiki source code of Monitoring
Last modified by Vincent Massol on 2024/06/26
Show last authors
author | version | line-number | content |
---|---|---|---|
1 | {{box cssClass="floatinginfobox" title="**Contents**"}} | ||
2 | {{toc/}} | ||
3 | {{/box}} | ||
4 | |||
5 | There are various solutions you can use to monitor a running XWiki instance: | ||
6 | |||
7 | * Install and configure [[Glowroot>>https://glowroot.org]] | ||
8 | * Install and configure [[JavaMelody>>https://github.com/javamelody/javamelody/wiki]] | ||
9 | * [[Use a Profiler>>dev:Community.Profiling]]. This has the advantage of providing advanced information, but has the drawback of being resource intensive and thus slowing the XWiki instance. It also requires a special startup script. | ||
10 | * XWiki is using the [[JMX Technology>>http://en.wikipedia.org/wiki/Java_Management_Extensions]] to provide runtime monitoring of XWiki instances. The following features are available: | ||
11 | ** Monitor the InfiniSpan caches XWiki is using to cache Document data, Users & Groups data and more | ||
12 | ** Monitor the JGroups channel and protocols (when the XWiki Cluster feature is turned on) | ||
13 | ** Monitor the Logback Logging configuration and change it | ||
14 | ** Monitor Solr | ||
15 | ** Monitor Apache DBCP connection pool | ||
16 | ** Monitor Hibernate | ||
17 | |||
18 | {{info}} | ||
19 | XWiki also has a [[Monitor Plugin>>Documentation.AdminGuide.Logging||anchor="HActivatingtheXWikiMonitoringfeature"]] that you can use to monitor execution times. However this plugin is going to be deprecated in the future and replaced by the JMX technology. | ||
20 | {{/info}} | ||
21 | |||
22 | = Glowroot = | ||
23 | |||
24 | {{image reference="glowroot.png" width="650px"/}} | ||
25 | |||
26 | There is nothing specific about XWiki when you install Glowroot, just follow [[the standard documentation>>https://github.com/glowroot/glowroot/wiki/Agent-Installation-%28with-Embedded-Collector%29]]. | ||
27 | |||
28 | = Hawtio = | ||
29 | |||
30 | {{image reference="hawtio.png" width="650px"/}} | ||
31 | |||
32 | * Installation in XWiki Standalone distribution: | ||
33 | ** Download the version with a JEE version supported by XWiki (e.g. Hawtio 3.x for versions of XWiki not supporting Jakarta EE) | ||
34 | ** Unwar the default Hawtio WAR in Jetty's ##webapps## directory next to the ##xwiki## directory | ||
35 | ** Set up [[authentication for Hawtio>>https://hawt.io/docs/security.html]] or disable authentication to try it. | ||
36 | *** You can edit ##start_xwiki.sh|bat## to add ##-Dhawtio.authenticationEnabled=false## to disable authentication | ||
37 | ** Access it through ##https://localhost:8080/hawtio## | ||
38 | |||
39 | = JavaMelody = | ||
40 | |||
41 | [[~[~[image:https://raw.githubusercontent.com/wiki/javamelody/javamelody/resources/screenshots/graphs.png~|~|width="50%"~]~]>>https://github.com/javamelody/javamelody/wiki/Screenshots#charts||style="width:50%"]] | ||
42 | |||
43 | To install JavaMelody for XWiki follow these steps (see the [[JavaMelody user guide>>https://github.com/javamelody/javamelody/wiki/UserGuide]] for more details): | ||
44 | |||
45 | * Download the latest 1.x version of [[javamelody.jar>>https://github.com/javamelody/javamelody/releases]] and [[jrobin-x.jar>>https://repo1.maven.org/maven2/org/jrobin/jrobin/1.5.9/jrobin-1.5.9.jar]] and put them in the ##WEB-INF/lib## folder | ||
46 | ** {{warning}}JavaMelody v2.x moved to Jakarta EE and is not compatible with XWiki{{/warning}} | ||
47 | * Edit ##web.xml## and add the following information:((( | ||
48 | {{code}} | ||
49 | ... | ||
50 | <filter> | ||
51 | <filter-name>monitoring</filter-name> | ||
52 | <filter-class>net.bull.javamelody.MonitoringFilter</filter-class> | ||
53 | </filter> | ||
54 | <!-- to enable BASIC authentication with username and password, but do no want to use a realm and "security-constraint" | ||
55 | The storage files of statistics and of graphs are stored in the temporary directory of the server, unless if you have defined the "storage-directory" path | ||
56 | <filter> | ||
57 | <filter-name>javamelody</filter-name> | ||
58 | <filter-class>net.bull.javamelody.MonitoringFilter</filter-class> | ||
59 | <init-param> | ||
60 | <param-name>authorized-users</param-name> | ||
61 | <param-value>user1:pwd1, user2:pwd2</param-value> | ||
62 | </init-param> | ||
63 | <init-param> | ||
64 | <param-name>storage-directory</param-name> | ||
65 | <param-value>/path/of/javamelody/stats</param-value> | ||
66 | </init-param> | ||
67 | </filter> --> | ||
68 | ... other <filter>s from the default web.xml here ... | ||
69 | |||
70 | <filter-mapping> | ||
71 | <filter-name>monitoring</filter-name> | ||
72 | <url-pattern>/*</url-pattern> | ||
73 | </filter-mapping> | ||
74 | ... other <filter-mapping>s from the default web.xml here ... | ||
75 | |||
76 | <listener> | ||
77 | <listener-class>net.bull.javamelody.SessionListener</listener-class> | ||
78 | </listener> | ||
79 | ... other <listener>s from the default web.xml here ... | ||
80 | ... | ||
81 | {{/code}} | ||
82 | ))) | ||
83 | * Edit ##hibernate.cfg.xml## and add:((( | ||
84 | {{code}} | ||
85 | <property name="jdbc.factory_class">net.bull.javamelody.HibernateBatcherFactory</property> | ||
86 | {{/code}} | ||
87 | ))) | ||
88 | |||
89 | Then restart XWiki and access JavaMelody at ##http:~/~/localhost:8080/xwiki/monitoring##. | ||
90 | |||
91 | {{warning}} | ||
92 | Recent versions of JavaMelody (at least 1.70+ ?) require the configuration in this guide to be adapted like this: | ||
93 | |||
94 | {{code}} | ||
95 | in web.xml: | ||
96 | ----------- | ||
97 | |||
98 | <filter> | ||
99 | <filter-name>javamelody</filter-name> | ||
100 | <filter-class>net.bull.javamelody.MonitoringFilter</filter-class> | ||
101 | <async-supported>true</async-supported> | ||
102 | </filter> | ||
103 | <filter-mapping> | ||
104 | <filter-name>javamelody</filter-name> | ||
105 | <url-pattern>/*</url-pattern> | ||
106 | <dispatcher>REQUEST</dispatcher> | ||
107 | <dispatcher>ASYNC</dispatcher> | ||
108 | </filter-mapping> | ||
109 | <listener> | ||
110 | <listener-class>net.bull.javamelody.SessionListener</listener-class> | ||
111 | </listener> | ||
112 | |||
113 | |||
114 | |||
115 | in hibernate.cfg.xml: | ||
116 | --------------------- | ||
117 | |||
118 | <property name="connection.driver_class">net.bull.javamelody.JdbcDriver</property> | ||
119 | <property name="connection.driver">com.mysql.jdbc.Driver</property> | ||
120 | {{/code}} | ||
121 | {{/warning}} | ||
122 | |||
123 | = JMX Console = | ||
124 | |||
125 | Since JMX is a standard you can use [[any JMX-compatible monitoring console>>http://stackoverflow.com/questions/1744900/what-is-the-best-or-most-commonly-used-jmx-console-client]] (most application servers provide a web-based JMX console). There's also a console called [[JConsole>>http://docs.oracle.com/javase/7/docs/technotes/guides/management/jconsole.html]] which is bundled by default in the Java Runtime you're using. To start it, simply execute the ##jconsole## executable. | ||
126 | |||
127 | {{info}} | ||
128 | Note that starting with XWiki 6.3, if you're using the Standalone Distribution (which bundles Jetty) you can now use ##start_xwiki.sh -j## (or ##start_xwiki.sh ~-~-jmx##) to monitor/manage the Jetty instance itself (it adds Jetty-specific MBeans): | ||
129 | |||
130 | {{image reference="jettymbeans.png"/}} | ||
131 | {{/info}} | ||
132 | |||
133 | == XWiki Caches Monitoring == | ||
134 | |||
135 | XWiki can use different cache implementations. The JBoss Cache and JBoss Infinispan implementations have nice JMX features available as shown below. | ||
136 | |||
137 | Starting with XWiki 3.3 the default implementation is JBoss Infinispan. | ||
138 | |||
139 | === With JBoss Infinispan === | ||
140 | |||
141 | Since JBoss Infinispan natively supports JMX we benefit from this feature directly (JBoss documentation available [[here>>https://docs.jboss.org/author/display/ISPN/Management+Tooling]]). | ||
142 | |||
143 | {{info}} | ||
144 | Prior to XWiki 3.5 the JMX support was not enabled by default. To enable it, edit ##WEB-INF/cache/infinispan/config.xml## and uncomment the two places where the "jmx" string is mentioned | ||
145 | {{/info}} | ||
146 | |||
147 | Example showing the cache list and some statistic for a given cache: | ||
148 | |||
149 | {{image reference="infinispancache.png"/}} | ||
150 | |||
151 | Example showing how to clear a given cache from all its entries: | ||
152 | |||
153 | {{image reference="infinispancacheclearing.png"/}} | ||
154 | |||
155 | === With JBoss Cache === | ||
156 | |||
157 | Since JBoss Cache natively supports JMX we benefit from this feature directly (JBoss documentation available [[here>>https://access.redhat.com/knowledge/docs/en-US/JBoss_Enterprise_Web_Platform/5/html/JBoss_Cache_User_Guide/jmx_reference.html]]). | ||
158 | |||
159 | Example showing all JBoss Caches in memory in a running instance, showing all the elements in the cache (example on the document cache): | ||
160 | |||
161 | {{image reference="jbosscache.png"/}} | ||
162 | |||
163 | Example showing Cache stats (for the document cache): | ||
164 | |||
165 | {{image reference="jbosscache-stats.png"/}} | ||
166 | |||
167 | == Velocity Cache Monitoring == | ||
168 | |||
169 | Velocity caches Velocity macros. XWiki offers a JMX view of the content of the Velocity caches. | ||
170 | |||
171 | JConsole examples showing the Velocity Cache monitoring: | ||
172 | |||
173 | {{image reference="jconsole1.png"/}} | ||
174 | |||
175 | {{image reference="jconsole2.png"/}} | ||
176 | |||
177 | == JGroups Monitoring == | ||
178 | |||
179 | JConsole example showing the JGroups monitoring: | ||
180 | |||
181 | {{image reference="jgroups.png"/}} | ||
182 | |||
183 | Interesting things to do on JGroups in the JMX console: | ||
184 | |||
185 | * Change the log level on the protocols to enable logging | ||
186 | * Disconnect a node from the cluster and reconnect it | ||
187 | |||
188 | == Logback Monitoring == | ||
189 | |||
190 | Since XWiki 14.8 Logback no longer support JMX so you won't be able to use JMX to update your logging configuration. | ||
191 | |||
192 | JConsole example showing how to modify the logging level for a category: | ||
193 | |||
194 | {{image reference="jmx-logging.png"/}} | ||
195 | |||
196 | = Tomcat JMX Proxy Servlet = | ||
197 | |||
198 | Tomcat has a JMX Proxy Servlet bundled in their ##manager## webapp (see [[here>>http://tomcat.apache.org/tomcat-6.0-doc/manager-howto.html]] and [[here>>http://tomcat.apache.org/tomcat-6.0-doc/monitoring.html]] for more details on Tomcat and JMX]]. | ||
199 | |||
200 | Here's some useful URLs to use the JMX Servlet Proxy to list and set JGroups Protocol Levels: | ||
201 | |||
202 | * To display the current log level for the TCPPING protocol: {{{http://localhost:8080/manager/jmxproxy?qry=jgroups:type=protocol,cluster=event,protocol=TCPPING}}} | ||
203 | * To set the log level to ##info## for the TCPPING protocol: {{{http://localhost:8080/manager/jmxproxy?set=jgroups:type=protocol,cluster=event,protocol=TCPPING&att=Level&val=info}}} | ||
204 | |||
205 | = Others = | ||
206 | |||
207 | * It's possible to [[write a Groovy script in a wiki page to access the JMX MBeans>>snippets:Extension.JMX Access]]. | ||
208 | * [[JMX Monitoring Application>>extensions:Extension.JMX Monitoring Application]] | ||
209 | * [[Clearing Document Caches with JMX>>snippets:Extension.Clear Document Caches.WebHome]] | ||
210 | * [[XInit>>extensions:Extension.Xinit]] |