Wiki source code of Monitoring
Version 32.1 by Vincent Massol on 2020/08/04
Hide last authors
author | version | line-number | content |
---|---|---|---|
![]() |
6.1 | 1 | {{box cssClass="floatinginfobox" title="**Contents**"}} |
2 | {{toc/}} | ||
3 | {{/box}} | ||
4 | |||
![]() |
13.2 | 5 | There are various solutions you can use to monitor a running XWiki instance: |
![]() |
26.1 | 6 | |
![]() |
29.1 | 7 | * Install and configure [[Glowroot>>https://glowroot.org]] |
![]() |
24.2 | 8 | * Install and configure [[JavaMelody>>https://github.com/javamelody/javamelody/wiki]] |
![]() |
26.1 | 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. |
![]() |
32.1 | 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: |
![]() |
31.2 | 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 | ||
![]() |
32.1 | 15 | ** Monitor Apache DBCP connection pool |
16 | ** Monitor Hibernate | ||
![]() |
1.1 | 17 | |
![]() |
2.3 | 18 | {{info}} |
![]() |
26.4 | 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. |
![]() |
2.3 | 20 | {{/info}} |
21 | |||
![]() |
29.1 | 22 | = Glowroot = |
23 | |||
![]() |
30.2 | 24 | {{image reference="glowroot.png" width="650px"/}} |
![]() |
29.1 | 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 | |||
![]() |
13.2 | 28 | = JavaMelody = |
29 | |||
![]() |
24.3 | 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%"]] |
![]() |
13.2 | 31 | |
![]() |
24.2 | 32 | To install JavaMelody for XWiki follow these steps (see the [[JavaMelody user guide>>https://github.com/javamelody/javamelody/wiki/UserGuide]] for more details): |
![]() |
26.1 | 33 | |
![]() |
24.2 | 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 |
![]() |
13.2 | 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> | ||
![]() |
25.1 | 42 | <!-- to enable BASIC authentication with username and password, but do no want to use a realm and "security-constraint" |
![]() |
28.1 | 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 |
![]() |
25.1 | 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> | ||
![]() |
28.1 | 51 | <init-param> |
52 | <param-name>storage-directory</param-name> | ||
53 | <param-value>/path/of/javamelody/stats</param-value> | ||
54 | </init-param> | ||
![]() |
25.1 | 55 | </filter> --> |
![]() |
13.2 | 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 | |||
![]() |
26.1 | 77 | Then restart XWiki and access JavaMelody at ##http:~/~/localhost:8080/xwiki/monitoring##. |
![]() |
13.2 | 78 | |
![]() |
27.1 | 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 | |||
![]() |
1.1 | 111 | = JMX Console = |
112 | |||
![]() |
17.3 | 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. |
![]() |
1.1 | 114 | |
![]() |
24.1 | 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): | ||
![]() |
22.1 | 117 | |
![]() |
24.1 | 118 | {{image reference="jettymbeans.png"/}} |
119 | {{/info}} | ||
120 | |||
![]() |
11.1 | 121 | == XWiki Caches Monitoring == |
122 | |||
![]() |
14.1 | 123 | XWiki can use different cache implementations. The JBoss Cache and JBoss Infinispan implementations have nice JMX features available as shown below. |
![]() |
11.1 | 124 | |
![]() |
17.3 | 125 | Starting with XWiki 3.3 the default implementation is JBoss Infinispan. |
![]() |
14.1 | 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 | |||
![]() |
17.3 | 131 | {{info}} |
![]() |
26.1 | 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 |
![]() |
17.3 | 133 | {{/info}} |
![]() |
14.1 | 134 | |
135 | Example showing the cache list and some statistic for a given cache: | ||
136 | |||
![]() |
17.3 | 137 | {{image reference="infinispancache.png"/}} |
![]() |
14.1 | 138 | |
![]() |
20.1 | 139 | Example showing how to clear a given cache from all its entries: |
140 | |||
141 | {{image reference="infinispancacheclearing.png"/}} | ||
142 | |||
![]() |
14.1 | 143 | === With JBoss Cache === |
144 | |||
![]() |
17.3 | 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]]). |
![]() |
14.1 | 146 | |
![]() |
11.1 | 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 | |||
![]() |
17.2 | 149 | {{image reference="jbosscache.png"/}} |
![]() |
11.1 | 150 | |
151 | Example showing Cache stats (for the document cache): | ||
152 | |||
![]() |
17.2 | 153 | {{image reference="jbosscache-stats.png"/}} |
![]() |
11.1 | 154 | |
![]() |
4.1 | 155 | == Velocity Cache Monitoring == |
![]() |
1.1 | 156 | |
![]() |
12.2 | 157 | Velocity caches Velocity macros. XWiki offers a JMX view of the content of the Velocity caches. |
158 | |||
![]() |
4.1 | 159 | JConsole examples showing the Velocity Cache monitoring: |
160 | |||
![]() |
17.2 | 161 | {{image reference="jconsole1.png"/}} |
![]() |
1.1 | 162 | |
![]() |
17.2 | 163 | {{image reference="jconsole2.png"/}} |
![]() |
1.1 | 164 | |
![]() |
4.1 | 165 | == JGroups Monitoring == |
166 | |||
167 | JConsole example showing the JGroups monitoring: | ||
168 | |||
![]() |
17.2 | 169 | {{image reference="jgroups.png"/}} |
![]() |
4.1 | 170 | |
171 | Interesting things to do on JGroups in the JMX console: | ||
![]() |
26.1 | 172 | |
![]() |
4.1 | 173 | * Change the log level on the protocols to enable logging |
174 | * Disconnect a node from the cluster and reconnect it | ||
175 | |||
![]() |
10.1 | 176 | == Logback Monitoring == |
177 | |||
178 | JConsole example showing how to modify the logging level for a category: | ||
179 | |||
![]() |
17.2 | 180 | {{image reference="jmx-logging.png"/}} |
![]() |
10.1 | 181 | |
![]() |
7.1 | 182 | = Tomcat JMX Proxy Servlet = |
183 | |||
184 | 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]]. | ||
185 | |||
186 | Here's some useful URLs to use the JMX Servlet Proxy to list and set JGroups Protocol Levels: | ||
![]() |
26.1 | 187 | |
![]() |
7.1 | 188 | * To display the current log level for the TCPPING protocol: {{{http://localhost:8080/manager/jmxproxy?qry=jgroups:type=protocol,cluster=event,protocol=TCPPING}}} |
189 | * 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}}} | ||
190 | |||
![]() |
18.1 | 191 | = Others = |
![]() |
7.1 | 192 | |
![]() |
28.2 | 193 | * It's possible to [[write a Groovy script in a wiki page to access the JMX MBeans>>snippets:Extension.JMX Access]]. |
![]() |
18.1 | 194 | * [[JMX Monitoring Application>>extensions:Extension.JMX Monitoring Application]] |
![]() |
31.1 | 195 | * [[Clearing Document Caches with JMX>>snippets:Extension.Clear Document Caches.WebHome]] |
![]() |
19.1 | 196 | * [[XInit>>extensions:Extension.Xinit]] |