2.25.3. Analysis of logs in GoAccess
GoAccess Is a free open source console program for viewing and analyzing web server logs. Designed for Linux and macOS. On Windows, you can use its implementation CowAxessrunning through Cygwin or directly through WSL.
To analyze logs using GoAccess, you need them first download.
To run the program in interactive mode, do the following:
- In the console, run the command substituting for
path/to/access.loglet the log file:
If you need to analyze several logs at once, specify the paths to them separated by a space:
goaccess path/to/access.log path/to/access.log.1
- Using the arrows and keys Space set the switch opposite "NCSA Combined Log Format" and press Enter.
- Wait for the log processing to complete.
The following modules are available in the program:
- "Unique visitors per day - Including spiders" - the number of unique visitors per day, including spiders.
- "Requested Files (URLs)" — requested URL.
- "Static Requests" — requests to static files.
- "Not Found URLs (404s)" - requests for which the server returned a response
- "Visitor Hostnames and IPs" — IP addresses, countries and hosts of visitors.
- "Operating Systems" - operating systems of visitors.
- "Browsers" — visitors' browsers.
- "Time Distribution" — distribution of requests by hours for.
- "Virtual Hosts" — virtual hosts. The module will be displayed only if there is relevant information in the log.
- "Referrers" (disabled by default) - URL from which visitors came.
- "Referring Sites" — sites from which visitors came.
- "Keyphrases" (disabled by default) - key phrases from Google search queries, Google cache (only HTTP requests are supported).
- "HTTP Status Codes" - server responses.
- "Remote User" — identifiers of persons requesting files with HTTP authentication. The module will be displayed only if there is relevant information in the log.
- "Geo Location" - the countries of the visitors.
To work with the program in interactive mode, use the following keys:
- F1 or h - call for help.
- F5 — updating information in the main window.
- q — exit from the program or minimize the active module.
- o or Enter — expanding the active module.
- 0…9 and Shift+0…5 — activation of the module by its number (Shift must be held for modules numbered 10+).
- ↑ — scrolling the contents of the main window up.
- ↓ - scroll down the contents of the main window.
- j — moving the cursor down inside the expanded module.
- k - moving the cursor upward inside the expanded module.
- c - setting or changing the color scheme.
- Ctrl+f — scrolling forward one screen inside the active module.
- Ctrl+b - scrolling back one screen inside the active module.
- Tab — switching to the next module.
- Shisft+Tab — switching to the previous module.
- s - sorting setting for the active module.
- / — search in all active modules (regular expressions can be used).
- n — search for the next match.
- g - go to the first element of the module or to the top of the main window.
- Shift+G - go to the last element of the module or down the main window.
Generating HTML report
--log-format='%h %^[%d:%t %^] "%r" %s %b "%R" "%u"' --date-format='%d/%b/%Y' --time-format='%T'.
Before generating HTML-report, specify the format of the log, date and time in the GoAccess configuration file:
- Find out the path to the GoAceess config file by running the command:
- Open the configuration file for editing by running the command:
- Add three lines to it:
log-format %h %^[%d:%t %^] "%r" %s %b "%R" "%u" date-format %d/%b/%Y time-format %T
- Save changes with the combination Ctrl+O.
- Exit the editor with the shortcut Ctrl+X
To generate HTML-report run the command:
goaccess path/to/access.log -a -o path/to/report.html
path/to/access.logsubstitute it for the log file.
path/to/report.htmlspecify the name of the report and the path where you want to save it.
Open the resulting file in any browser. The report will clearly reflect information on all available modules with the ability to customize the display.