Wiki source code of Monitoring

Last modified by Antoine Mottier on 2023/07/17

Show last authors
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 cores
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 = JavaMelody =
29
30 [[~[~[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%"]]
31
32 To install JavaMelody for XWiki follow these steps (see the [[JavaMelody user guide>>https://github.com/javamelody/javamelody/wiki/UserGuide]] for more details):
33
34 * Download the latest [[javamelody.jar>>https://github.com/javamelody/javamelody/releases]] and [[jrobin-x.jar>>https://github.com/javamelody/javamelody/releases/download/javamelody-core-1.49.0/jrobin-1.5.9.jar]] and put them in the ##WEB-INF/lib## folder
35 * Edit ##web.xml## and add the following information:(((
36 {{code}}
37 ...
38 <filter>
39 <filter-name>monitoring</filter-name>
40 <filter-class>net.bull.javamelody.MonitoringFilter</filter-class>
41 </filter>
42 <!-- to enable BASIC authentication with username and password, but do no want to use a realm and "security-constraint"
43 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
44 <filter>
45 <filter-name>javamelody</filter-name>
46 <filter-class>net.bull.javamelody.MonitoringFilter</filter-class>
47 <init-param>
48 <param-name>authorized-users</param-name>
49 <param-value>user1:pwd1, user2:pwd2</param-value>
50 </init-param>
51 <init-param>
52 <param-name>storage-directory</param-name>
53 <param-value>/path/of/javamelody/stats</param-value>
54 </init-param>
55 </filter> -->
56 ... other <filter>s from the default web.xml here ...
57
58 <filter-mapping>
59 <filter-name>monitoring</filter-name>
60 <url-pattern>/*</url-pattern>
61 </filter-mapping>
62 ... other <filter-mapping>s from the default web.xml here ...
63
64 <listener>
65 <listener-class>net.bull.javamelody.SessionListener</listener-class>
66 </listener>
67 ... other <listener>s from the default web.xml here ...
68 ...
69 {{/code}}
70 )))
71 * Edit ##hibernate.cfg.xml## and add:(((
72 {{code}}
73 <property name="jdbc.factory_class">net.bull.javamelody.HibernateBatcherFactory</property>
74 {{/code}}
75 )))
76
77 Then restart XWiki and access JavaMelody at ##http:~/~/localhost:8080/xwiki/monitoring##.
78
79 {{warning}}
80 Recent versions of JavaMelody (at least 1.70+ ?) require the configuration in this guide to be adapted like this:
81
82 {{code}}
83 in web.xml:
84 -----------
85
86 <filter>
87 <filter-name>javamelody</filter-name>
88 <filter-class>net.bull.javamelody.MonitoringFilter</filter-class>
89 <async-supported>true</async-supported>
90 </filter>
91 <filter-mapping>
92 <filter-name>javamelody</filter-name>
93 <url-pattern>/*</url-pattern>
94 <dispatcher>REQUEST</dispatcher>
95 <dispatcher>ASYNC</dispatcher>
96 </filter-mapping>
97 <listener>
98 <listener-class>net.bull.javamelody.SessionListener</listener-class>
99 </listener>
100
101
102
103 in hibernate.cfg.xml:
104 ---------------------
105
106 <property name="connection.driver_class">net.bull.javamelody.JdbcDriver</property>
107 <property name="connection.driver">com.mysql.jdbc.Driver</property>
108 {{/code}}
109 {{/warning}}
110
111 = JMX Console =
112
113 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.
114
115 {{info}}
116 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):
117
118 {{image reference="jettymbeans.png"/}}
119 {{/info}}
120
121 == XWiki Caches Monitoring ==
122
123 XWiki can use different cache implementations. The JBoss Cache and JBoss Infinispan implementations have nice JMX features available as shown below.
124
125 Starting with XWiki 3.3 the default implementation is JBoss Infinispan.
126
127 === With JBoss Infinispan ===
128
129 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]]).
130
131 {{info}}
132 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
133 {{/info}}
134
135 Example showing the cache list and some statistic for a given cache:
136
137 {{image reference="infinispancache.png"/}}
138
139 Example showing how to clear a given cache from all its entries:
140
141 {{image reference="infinispancacheclearing.png"/}}
142
143 === With JBoss Cache ===
144
145 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]]).
146
147 Example showing all JBoss Caches in memory in a running instance, showing all the elements in the cache (example on the document cache):
148
149 {{image reference="jbosscache.png"/}}
150
151 Example showing Cache stats (for the document cache):
152
153 {{image reference="jbosscache-stats.png"/}}
154
155 == Velocity Cache Monitoring ==
156
157 Velocity caches Velocity macros. XWiki offers a JMX view of the content of the Velocity caches.
158
159 JConsole examples showing the Velocity Cache monitoring:
160
161 {{image reference="jconsole1.png"/}}
162
163 {{image reference="jconsole2.png"/}}
164
165 == JGroups Monitoring ==
166
167 JConsole example showing the JGroups monitoring:
168
169 {{image reference="jgroups.png"/}}
170
171 Interesting things to do on JGroups in the JMX console:
172
173 * Change the log level on the protocols to enable logging
174 * Disconnect a node from the cluster and reconnect it
175
176 == Logback Monitoring ==
177
178 Since XWiki 14.8 Logback no longer support JMX so you won't be able to use JMX to update your logging configuration.
179
180 JConsole example showing how to modify the logging level for a category:
181
182 {{image reference="jmx-logging.png"/}}
183
184 = Tomcat JMX Proxy Servlet =
185
186 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]].
187
188 Here's some useful URLs to use the JMX Servlet Proxy to list and set JGroups Protocol Levels:
189
190 * To display the current log level for the TCPPING protocol: {{{http://localhost:8080/manager/jmxproxy?qry=jgroups:type=protocol,cluster=event,protocol=TCPPING}}}
191 * 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}}}
192
193 = Others =
194
195 * It's possible to [[write a Groovy script in a wiki page to access the JMX MBeans>>snippets:Extension.JMX Access]].
196 * [[JMX Monitoring Application>>extensions:Extension.JMX Monitoring Application]]
197 * [[Clearing Document Caches with JMX>>snippets:Extension.Clear Document Caches.WebHome]]
198 * [[XInit>>extensions:Extension.Xinit]]

Get Connected