Go access Manual Page
Manual Page
NAME
goaccess - Fast web log analyzer and interactive viewer.
SYNOPSIS
goaccess -f log [-c][-r][-m][-h][-q][-d][-g][-a][-o csv|json][-e IP_ADDRESS][...]
DESCRIPTION
goaccess is a free (MIT Licensed) and open source real-time web log analyzer and interactive viewer that runs in a terminal in *nix systems or through your browser.
It provides fast and valuable HTTP statistics for system administrators that require a visual server report on the fly. GoAccess parses the specified web log file and outputs the data to the X terminal. Features include:
- General Statistics: This panel gives a summary of several metrics, some of them are: number of valid and invalid requests, time taken to analyze the data set, unique visitors, requested files, static files (CSS, ICO, JPG, etc) HTTP referrers, 404s, size of the parsed log file and bandwidth con‐ sumption.
- Unique visitors: This panel shows metrics such as hits, unique visitors and cumulative bandwidth per date. HTTP requests containing the same IP, the same date, and the same user agent are considered a unique visitor. By default, it includes web crawlers/spiders.
Optionally, date specificity can be set to the hour level using --date-spec=hr which will display dates such as 05/Jun/2016:16. This is great if you want to track your daily traffic at the hour level. - Requested files: This panel displays the most highly requested files on your web server. It shows hits, unique visitors, and percentage, along with the cumulative bandwidth, protocol, and the request method used.
-
Requested static files:
Lists the most frequently static files such as:
JPG,CSS,SWF,JS,GIF, andPNGfile types, along with the same metrics as the last panel. Additional static files can be added to the configuration file. - 404 or Not Found: Displays the same metrics as the previous request panels, however, its data contains all pages that were not found on the server, or commonly known as 404 status code.
-
Hosts:
This panel has detailed information on the hosts themselves. This
is great for spotting aggressive crawlers and identifying who's eating
your bandwidth.
Expanding the panel can display more information such as host's reverse DNS lookup result, country of origin and city. If the-aargument is enabled, a list of user agents can be displayed by selecting the desired IP address, and then pressing ENTER. - Operating Systems: This panel will report which operating system the host used when it hit the server. It attempts to provide the most specific version of each operating system.
- Browsers: This panel will report which browser the host used when it hit the server. It attempts to provide the most specific version of each browser.
-
Visit Times:
This panel will display an hourly report. This option displays 24 data points, one for each hour of the day.
Optionally, hour specificity can be set to the tenth of a minute level using --hour-spec=min which will display hours as 16:4 This is great if you want to spot peaks of traffic on your server. - Virtual Hosts: This panel will display all the different virtual hosts parsed from the access log. This panel is displayed if %v is used within the log-format string.
-
Referrers URLs:
If the host in question accessed the site via another resource, or
was linked/diverted to you from another host, the URL they were
referred from will be provided in this panel. See
`--ignore-panel`in your configuration file to enable it. (disabled by default) - Referring Sites: This panel will display only the host part but not the whole URL. The URL where the request came from.
-
Keyphrases:
It reports keyphrases used on Google search, Google cache, and
Google translate that have led to your web server. At present, it only
supports Google search queries via HTTP. See
`--ignore-panel`in your configuration file to enable it. (disabled by default) - Geo Location: Determines where an IP address is geographically located. Statistics are broken down by continent and country. It needs to be compiled with GeoLocation support.
- HTTP Status Codes: The values of the numeric status code to HTTP requests.
NOTE: Optionally and if configured, all panels can display the average time taken to serve the request.
STORAGE
There are three storage options that can be used with GoAccess. Choosing one will depend on your environment and needs.
Default Hash Tables
In-memory storage provides better performance at the cost of limiting the dataset size to the amount of available physical memory. By default GoAccess uses in-memory hash tables. If your dataset can fit in memory, then this will perform fine. It has very good memory usage and pretty good performance.
Tokyo Cabinet On-Disk B+ Tree
Use this storage method for large datasets where it is not possible to fit everything in memory. The B+ tree database is slower than any of the hash databases since data has to be committed to disk. However, using an SSD greatly increases the performance. You may also use this storage method if you need data persistence to quickly load statistics at a later date.
Tokyo Cabinet In-memory Hash Database
An alternative to the default hash tables. It uses generic typing and thus it's performance in terms of memory and speed is average.
CONFIGURATION
Multiple options can be used to configure GoAccess. For a complete up-to-date list of configure options, run ./configure --help
--enable-debug- Compile with debugging symbols and turn off compiler optimizations.
--enable-utf8- Compile with wide character support. Ncursesw is required.
--enable-geoip- Compile with GeoLocation support. MaxMind's GeoIP is required.
--enable-tcb=<memhash|btree>-
Compile with Tokyo Cabinet storage support.
memhashwill utilize Tokyo Cabinet's in-memory hash database.btreewill utilize Tokyo Cabinet's on-disk B+ Tree database. --disable-zlib- Disable zlib compression on B+ Tree database.
--disable-bzip- Disable bzip2 compression on B+ Tree database.
--with-getline- Use GNU getline() to parse full line requests instead of a fixed size buffer of 4096.
OPTIONS
The following options can be supplied via the command line or long options through the configuration file.
LOG/DATE/TIME FORMAT
-
--time-format <timeformat>
The time-format variable followed by a space, specifies the log format time containing any combination of regular characters and special format specifiers. They all begin with a percentage (%) sign. See `man strftime`. %T or %H:%M:%S.
-
--date-format <dateformat>
The date-format variable followed by a space, specifies the log format date containing any combination of regular characters and special format specifiers.They all begin with a percentage (%) sign. See `man strftime`.
-
--log-format <logformat>
The log-format variable followed by a space or
\tfor tab-delimited, specifies the log format string.Note: Generally, you need quotes around values that include white spaces, commas, pipes, quotes, and/or brackets. Inner quotes must be escaped.
USER INTERFACE OPTIONS
-
-c --config-dialog
Prompt log/date configuration window on program start.
-
-i --hl-header
Color highlight active panel.
-
-m --with-mouse
Enable mouse support on main dashboard.
- --color=<fg:bg[attrs, PANEL>
Specify custom colors for the terminal output.
Color Syntax:
DEFINITION space/tab colorFG#:colorBG# [attributes,PANEL]FG# = foreground color [-1...255] (-1 = default term color) BG# = background color [-1...255] (-1 = default term color)
Optionally, it is possible to apply color attributes (multiple attributes are comma separated), such as:
bold,underline,normal,reverse,blinkIf desired, it is possible to apply custom colors per panel, that is, a metric in the REQUESTS panel can be of color A, while the same metric in the BROWSERS panel can be of color B.
See configuration file for a sample color scheme.
- --color-scheme <1|2|3>
Choose among terminal color schemes.
1for the monochrome scheme.2for the green scheme and3for the Monokai scheme (shown only if terminal supports 256 colors). - --html-custom-css=<path.css>
Specifies a custom CSS file path to load in the HTML report.
- --html-custom-js=<path.js>
Specifies a custom JS file path to load in the HTML report.
- --html-report-title
Set HTML report page title and header.
- --json-pretty-print
Format JSON output using tabs and newlines.
Note: Generally, you need quotes around values that include white spaces, commas, pipes, quotes, and/or brackets. Inner quotes must be escaped. -
--max-items=<num>
The maximum number of items to display per panel. The maximum can be a number between 1 and n.
Note: Only the CSV and JSON output allow a maximum number greater than the default value of 366 (or 50 in the real-time HTML output) items per panel. -
--no-color
Turn off colored output. This is the default output on terminals that do not support colors.
-
--no-column-names
Don't write column names in the terminal output. By default, it displays column names for each available metric in every panel.
-
--no-csv-summary
Disable summary metrics on the CSV output.
-
--no-progress
Disable progress metrics [total requests/requests per second] when parsing a log.
-
--no-tab-scroll
Disable scrolling through panels when TAB is pressed or when a panel is selected using a numeric key.
SERVER OPTIONS
-
--addr=<address>
Specify IP address to bind the server to. Otherwise it binds to 0.0.0.0.
Usually there is no need to specify the address, unless you intentionally would like to bind the server to a different address within your server.
-
--origin=<url>
Ensure clients send the specified origin header upon the WebSocket handshake. The specified origin should look exactly to the origin header field sent by the browser. e.g.,
--origin=http://goaccess.io -
--port=<port>
Specify the port to use. By default GoAccess listens on port 7890 for the WebSocket server.
-
--real-time-html
Enable real-time HTML output.
-
--ws-url=<url[:port]>
URL to which the WebSocket server responds. This is the URL supplied to the WebSocket con‐ structor on the client side.
If GoAccess is running behind a proxy, you could set the client side to connect to a different port by specifying the host followed by a colon and the port. e.g.,
goaccess.io:9999By default, it will attempt to connect to localhost. If GoAccess is running on a remote server, the host of the remote server should be specified here. Also, make sure it is a valid host and NOT an http address.
FILE OPTIONS
-
-f --log-file=<logfile>
Specify the path to the input log file. If set in the config file, it will take priority over
-ffrom the command line. -
-l --log-debug=<filename>
Send all debug messages to the specified file. Needs to be configured with
--enable-debug -
-p --config-file <configfile>
Specify a custom configuration file to use. If set, it will take priority over the global configuration file (if any).
-
--invalid-requests <filename>
Log invalid requests to the specified file.
-
--no-global-config
Do not load the global configuration file. This directory should normally be
/usr/etc/,/etc/or/usr/local/etc/, unless specified with--sysconfdir=/dirat the time of running ./configure
PARSE OPTIONS
-
-a --agent-list
Enable a list of user-agents by host. For faster parsing, do not enable this flag.
-
-d --with-output-resolver
Enable IP resolver on the
HTMLorJSONoutput. -
-e --exclude-ip <IP|IP-range>
Exclude an IPv4 or IPv6 from being counted. Ranges can be included as well using a dash in between the IPs (start-end).
-
-H --http-protocol=<yes|no>
Set/unset HTTP request protocol. This will create a request key containing the request protocol + the actual request.
-
-M --http-method=<yes|no>
Set/unset HTTP request method. This will create a request key containing the request method + the actual request.
-
-o --output=<json|csv>
Write output to stdout given one of the following files and the corresponding extension for the output format:
-
-q --no-query-string
Ignore request's query string. i.e., www.google.com/page.htm?query => www.google.com/page.htm
Note: Removing the query string can greatly decrease memory consumption, especially on timestamped requests. -
-r --no-term-resolver
Disable IP resolver on terminal output.
-
--444-as-404
Treat non-standard status code 444 as 404.
-
--4xx-to-unique-count
Add 4xx client errors to the unique visitors count.
-
--all-static-files
Include static files that contain a query string.
-
--date-spec=<date|hr>
Set the date specificity to either date (default) or hr to display hours appended to the date.
This is used in the visitors panel. It's useful for tracking visitors at the hour level. For instance, an hour specificity would yield to display traffic as 18/Dec/2010:19 -
--date-spec=<date|hr>
Set the date specificity to either date (default) or hr to display hours appended to the date.
This is used in the visitors panel. It's useful for tracking visitors at the hour level. For instance, an hour specificity would yield to display traffic as 18/Dec/2010:19 -
--double-decode
Decode double-encoded values. This includes, user-agent, request, and referer.
-
--enable-panel=<PANEL>
Enable parsing/displaying the given panel. List of panels:
-
--hour-spec=<hour|min>
Set the time specificity to either hour (default) or min to display the tenth of an hour appended to the hour.
This is used in the time distribution panel. It's useful for tracking peaks of traffic on your server at specific times. -
--ignore-crawlers
Ignore crawlers.
-
--ignore-panel=<PANEL>
Ignore parsing/displaying the given panel. List of panels:
-
--ignore-referer=<referer>
Ignore referers from being counted. Wildcards allowed. e.g.,
*.domain.comww?.domain.* -
--ignore-status=<STATUS>
Ignore parsing and displaying one or multiple status code(s). For multiple status codes, use this option multiple times.
-
--real-os
Display real OS names. e.g, Windows XP, Snow Leopard.
-
--sort-panel=<PANEL,FIELD,ORDER>
Sort panel on initial load. Sort options are separated by comma. Options are in the form: PANEL,METRIC,ORDER
Available orders
Available Metrics -
--static-file <extension>
Add static file extension. e.g.:
.mp3. Extensions are case sensitive.
GEOLOCATION OPTIONS
-
-g --std-geoip
Standard GeoIP database for less memory usage.
-
--geoip-database <geocityfile>
Specify path to GeoIP database file. i.e., GeoLiteCity.dat. File needs to be downloaded from maxmind.com. IPv4 and IPv6 files are supported as well. Note:
--geoip-city-datais an alias of--geoip-database.
OTHER OPTIONS
-
-h --help
The help.
-
-V --version
Display version information and exit.
-
-s --storage
Display current storage method. i.e., B+ Tree, Hash.
-
--dcf
Display the path of the default config file when
-pis not used.
ON-DISK STORAGE OPTIONS
-
--keep-db-files
Persist parsed data into disk. If database files exist, files will be overwritten. This should be set to the first dataset. Setting it to false will delete all database files when exiting the program. See examples below.
Only if configured with --enable-tcb=btree
-
--load-from-disk
Load previously stored data from disk. If reading persisted data only, the database files need to exist. See keep-db-files and examples below. See
keep-db-filesand examples below.Only if configured with --enable-tcb=btree
-
--db-path <dir>
Path where the on-disk database files are stored. The default value is the
/tmpdirectory.Only if configured with --enable-tcb=btree
-
--xmmap <num>
Set the size in bytes of the extra mapped memory. The default value is 0.
Only if configured with --enable-tcb=btree
-
--cache-lcnum <num>
Specifies the maximum number of leaf nodes to be cached. If it is not more than 0, the default value is specified. The default value is 1024. Setting a larger value will increase speed performance, however, memory consumption will increase. Lower value will decrease memory consumption.
Only if configured with --enable-tcb=btree
-
--cache-ncnum <num>
Specifies the maximum number of non-leaf nodes to be cached. If it is not more than 0, the default value is specified. The default value is 512.
Only if configured with --enable-tcb=btree
-
--tune-lmemb <num>
Specifies the number of members in each leaf page. If it is not more than 0,the default value is specified. The default value is 128.
Only if configured with --enable-tcb=btree
-
--tune-nmemb <num>
Specifies the number of members in each non-leaf page. If it is not more than 0, the default value is specified. The default value is 256.
Only if configured with --enable-tcb=btree
-
--tune-bnum <num>
Specifies the number of elements of the bucket array. If it is not more than 0, the default value is specified. The default value is 32749. Suggested size of the bucket array is about from 1 to 4 times of the number of all pages to be stored.
Only if configured with --enable-tcb=btree
-
--compression <zlib|bz2>
Specifies that each page is compressed with ZLIB|BZ2 encoding.
Only if configured with --enable-tcb=btree
CUSTOM LOG/DATE FORMAT
GoAccess can parse virtually any web log format.
Predefined options include, Common Log Format (CLF), Combined Log Format (XLF/ELF), including virtual host, W3C format (IIS) and Amazon CloudFront (Download Distribution).
GoAccess allows any custom format string as well.
There are two ways to configure the log format. The easiest is to run GoAccess with -c
to prompt a configuration window. However this won't make it permanent,
for that you will need to specify the format in the configuration file.
The configuration file resides under:
%sysconfdir%/goaccess.conf or ~/.goaccessrc
Note %sysconfdir% is either
/etc/, /usr/etc/ or /usr/local/etc/
time-format The time-format variable followed by a
space, specifies the log format date containing any combination of
regular characters and special format specifiers. They all begin with a
percentage (%) sign. See `man strftime`. %T or
%H:%M:%S.
Note: If a timestamp is given in microseconds, %f must be used as time-format
date-format The date-format variable followed by a space, specifies the log format date containing any combination of regular characters and special format specifiers. They all begin with a percentage (%) sign. See `man strftime`.
Note: If a timestamp is given in microseconds, %f must be used as date-format
log-format The log-format variable followed by a space or \t for tab-delimited, specifies the log format string.
SPECIFIERS
-
%xA date and time field matching the time-format and date-format variables. This is used when a timestamp is given instead of the date and time being in two separate variables. -
%ttime field matching the time-format variable. -
%ddate field matching the date-format variable. -
%vThe server name according to the canonical name setting (Server Blocks or Virtual Host). -
%hhost (the client IP address, either IPv4 or IPv6) -
%rThe request line from the client. This requires specific delimiters around the request (as single quotes, double quotes, or anything else) to be parsable. If not, we have to use a combination of special format specifiers as %m %U %H. -
%qThe query string. -
%mThe request method. -
%UThe URL path requested. -
Note: If the query string is in
%U, there is no need to use%q. However, if the URL path, does not include any query string, you may use%qand the query string will be appended to the request. -
%HThe request protocol. -
%sThe status code that the server sends back to the client. -
%bThe size of the object returned to the client. -
%RThe "Referer" HTTP request header. -
%uThe user-agent HTTP request header. -
%DThe time taken to serve the request, in microseconds. -
%TThe time taken to serve the request, in seconds with milliseconds resolution. -
%LThe time taken to serve the request, in milliseconds as a decimal number. - Note: If multiple time served specifiers are used at the same time, the first option specified in the format string will take priority over the other specifiers.
-
%^Ignore this field. -
%~Move forward through the log string until a non-space (!isspace) char is found.
GoAccess requires the following fields:
- a valid IPv4/6
%h - a valid date
%d - the request
%r
INTERACTIVE KEYS
F1orhMain help.F5Redraw main window.qQuit the program, current window or collapse active moduleoorENTERExpand selected module or open window0-9andShift + 0Set selected module to activejScroll down within expanded modulekScroll up within expanded modulecSet or change scheme color^ fScroll forward one screen within active module^ bScroll backward one screen within active moduleTABIterate modules (forward)SHIFT + TABIterate modules (backward)sSort options for active module/Search across all modules (regex allowed)nFind position of the next occurrencegMove to the first item or top of screenGmove to the last item or bottom of screen
EXAMPLES
DIFFERENT OUTPUTS
To output to a terminal and generate an interactive report:
# goaccess -f access.log
To generate an HTML report:
# goaccess -f access.log -a -o report.html
To generate a JSON report:
# goaccess -f access.log -a -d -o report.json
To generate a CSV file:
# goaccess -f access.log --no-csv-summary -o report.csv
- The
-aflag indicates that we want to process an agent-list for every host parsed. - The
-dflag indicates that we want to enable the IP resolver on the HTML | JSON output.(It will take longer time to output since it has to resolve all queries.) - The
-cflag will prompt the date and log format configuration window. Only when curses is initialized.
REAL TIME HTML OUTPUT
GoAccess has the ability the output real-time data in the HTML report. You can even email the HTML file since it is composed of a single file with no external file dependencies, how neat is that!
To output an HTML report and set the WebSocket server to listen on port 7890 and localhost.
# goaccess -f access.log -o report.html --real-time-html
If GoAccess is running on a specific host, you can specify the URL to which to connect. See FAQ for a more detailed example.
# goaccess -f access.log -o report.html --real-time-html --ws-url=goaccess.io
To use a different port other than 7890, you can specify it as:
# goaccess -f access.log -o report.html --real-time-html --ws-url=goaccess.io --port=9870
And to bind the WebSocket server to a different address other than 0.0.0.0, you can specify it as:
# goaccess -f access.log -o report.html --real-time-html --ws-url=goaccess.io --addr=127.0.0.1
MULTIPLE LOG FILES
Now if we want to add more flexibility to GoAccess, we can do a series of pipes. For instance:
If we would like to process all access.log.*.gz we can do one of the following:
# zcat -f access.log* | goaccess
# zcat access.log.*.gz | goaccess
Note: On Mac OS X, use gunzip -c instead of zcat.
WORKING WITH DATES
Another useful pipe would be filtering dates out of the web log
The following will get all HTTP requests starting on 05/Dec/2010 until the end of the file.
# sed -n '/05\/Dec\/2010/,$ p' access.log | goaccess -a
or using relative dates such as yesterdays or tomorrows day:
# sed -n '/'$(date '+%d\/%b\/%Y' -d '1 week ago')'/,$ p' access.log | goaccess -a
If we want to parse only a certain time-frame from DATE a to DATE b, we can do:
# sed -n '/5\/Nov\/2010/,/5\/Dec\/2010/ p' access.log | goaccess -a
VIRTUAL HOSTS
Assuming your log contains the virtual host field. For instance:
vhost.com:80 10.131.40.139 - - [02/Mar/2016:08:14:04 -0600] "GET /shop/bag-p-20 HTTP/1.1" 200 6715 "-" "Apache (internal dummy connection)"
And you would like to append the virtual host to the request in order to see which virtual host the top urls belong to
awk '$8=$1$8' access.log | goaccess -a
To exclude a list of virtual hosts you can do the following:
# grep -v "`cat exclude_vhost_list_file`" vhost_access.log | goaccess
FILES & STATUS CODES
To parse specific pages, e.g., page views, html, htm, php, etc. within a request:
# awk '$7~/\.html|\.htm|\.php/' access.log | goaccess
Note, $7 is the request field for the common and combined log format, (without Virtual Host), if your log includes Virtual Host, then you probably want to use $8 instead. It's best to check which field you are shooting for, e.g.:
# tail -10 access.log | awk '{print $8}'
Or to parse a specific status code, e.g., 500 (Internal Server Error):
# awk '$9~/500/' access.log | goaccess
SERVER
Also, it is worth pointing out that if we want to run GoAccess at lower priority, we can run it as:
# nice -n 19 goaccess -f access.log -a
and if you don't want to install it on your server, you can still run it from your local machine:
# ssh root@server 'cat /var/log/apache2/access.log' | goaccess -a
PROCESSING LOGS INCREMENTALLY
GoAccess has the ability to process logs incrementally through the on-disk B+Tree database. It works in the following way:
- A data set must be persisted first with
--keep-db-files, then the same data set can be loaded with--load-from-disk. - If new data is passed (piped or through a log file), it will append it to the original data set.
- To preserve the data at all times,
--keep-db-filesmust be used. - If
--load-from-diskis used without--keep-db-files, database files will be deleted upon closing the program.
Examples
// last month access log goaccess -f access.log.1 --keep-db-files
then, load it with
// append this month access log, and preserve new data goaccess -f access.log --load-from-disk --keep-db-files
To read persisted data only (without parsing new data)
goaccess --load-from-disk --keep-db-files
NOTES
Each active panel has a total of 366 items or 50 in the real-time HTML report. The number of items is customizable using max-items However, only the CSV and JSON output allow a maximum number greater than the default value of 366 items per panel.
Piping a log to GoAccess will disable the real-time functionality. This is due to the portability issue on determining the actual size of STDIN. However, a future release *might* include this feature.
A hit is a request (line in the access log), e.g., 10 requests = 10 hits. HTTP requests with the same IP, date, and user agent are considered a unique visit.
BUGS
If you think you have found a bug, please send me an email to
AUTHOR
Gerardo Orellana. For more details about it, or new releases, please visit http://goaccess.io

浙公网安备 33010602011771号