Skip to content

Instantly share code, notes, and snippets.

@aitseitz
Last active September 29, 2023 16:14
Show Gist options
  • Save aitseitz/8d05d69f0167f0e6d0b006dfaa3a2e26 to your computer and use it in GitHub Desktop.
Save aitseitz/8d05d69f0167f0e6d0b006dfaa3a2e26 to your computer and use it in GitHub Desktop.

Tomcat access.log Analyse with GoAccess

  1. Download & Install GoAccess: https://goaccess.io/download
sudo apt install goaccess
  1. Check your Tomcat Access_Log_Valve pattern

https://tomcat.apache.org/tomcat-9.0-doc/config/valve.html#Access_Log_Valve

For Example:

        <Valve className="org.apache.catalina.valves.AccessLogValve"
            directory="{{ tomcat_log_dir }}"
            rotatable="false"
            prefix="access.log"
            pattern="%t %h %l %u %r %s %b %D"
            requestAttributesEnabled="true"
        />
  1. Map Access_Log_Valve Pattern to the GoAccess CUSTOM LOG/DATE FORMAT

Check your tomcat access.log format:

[22/May/2023:03:17:00 +0200] 192.116.174.250 - - POST /alfresco/service/api/solr/modelsdiff HTTP/1.1 200 37 19
[22/May/2023:03:17:00 +0200] 192.116.174.250 - - GET /alfresco/service/api/solr/aclchangesets?fromTime=1684718210001&toTime=1684725410001&maxResults=2000 HTTP/1.1 200 130 4
[22/May/2023:03:17:00 +0200] 192.116.174.250 - - GET /alfresco/service/api/solr/transactions?fromCommitTime=1684717200436&toCommitTime=1684720800436&maxResults=2000 HTTP/1.1 200 254 4
[22/May/2023:03:17:00 +0200] 192.116.174.250 - - GET /alfresco/service/api/solr/aclchangesets?fromTime=1684718210001&toTime=1684725410001&maxResults=2000 HTTP/1.1 200 130 5
[22/May/2023:03:17:00 +0200] 192.116.174.250 - - GET /alfresco/service/api/solr/transactions?fromCommitTime=1684720800436&toCommitTime=1684724400436&maxResults=2000 HTTP/1.1 200 119 4
[22/May/2023:03:17:00 +0200] 192.116.174.250 - - GET /alfresco/service/api/solr/transactions?fromCommitTime=1684717200436&toCommitTime=1684720800436&maxResults=2000 HTTP/1.1 200 254 3

an map the Valve Pattern to the SPECIFIERS at https://goaccess.io/man#custom-log and build your go access log Format:

goaccess --date-format='%d/%b/%Y' --time-format='%H:%M:%S' --log-format='[%d:%t %^] %h %^ %^ %m %r %H %s %b %T' -f access.log
  1. Add Additional Output Format to display the statistics in a webbrowser:
goaccess --date-format='%d/%b/%Y' --time-format='%H:%M:%S' --log-format='[%d:%t %^] %h %^ %^ %m %r %H %s %b %T' -f access.log --output=html --hour-spec=hour -a > access_log_goaccess.html
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment