Repository navigation
TomcatAccessLog
XCollector is able to extract operational metrics like the request rate, request latency, error rate etc from Tomcat access logs.
Update Tomcat configuration to generate access logs in XCollector friendly format
vi /etc/tomcat/server.xml
And update the settings for AccessLogValve
<Valve className="org.apache.catalina.valves.AccessLogValve" directory="logs"
prefix="localhost_access" suffix=".log"
pattern="%h %l %u %t "%r" %s %b "%{Referer}i" "%{User-Agent}i" %T" renameOnRotate="true"/>This changes couple of settings:
-
Tomcat Access Log file name changes dynamically with time (Ex:
localhost_access2017-09-13.log) by default. XCollector currently supports watching files with fixed names. TherenameOnRotate="true"option instructs Tomcat to add date to the filename only on a rotation.
The optionsprefix="localhost_access" suffix=".log"directs Tomcat to write the access logs tolocalhost_access.logfile -
The
patternoption directs Tomcat to log time taken to process the request (%T). This data is parsed by XCollector to generate the response latency metrics
Restart Tomcat to pick up these settings:
sudo service tomcat restart
Xcollector runs as user xcollector. Make sure the xcollector user has read
permission on the access log file.
XCollector looks for Tomcat access logs by default at the following location: /var/log/tomcat/localhost_access.log. If your access logs are in a
different location, update the input.path option in grok_tomcat.yml file
(vi /etc/xcollector/grok_tomcat.yml)
Restart the XCollector service (sudo service xcollector restart).