GoAccess ist ein schneller, interaktiver Weblog-Analyzer. Er läuft im Terminal oder erzeugt HTML-Berichte in Echtzeit.

Installation

Debian/Ubuntu

apt install goaccess

Aus Repository (aktuellere Version)

wget -O - https://deb.goaccess.io/gnugpg.key | gpg --dearmor > /etc/apt/trusted.gpg.d/goaccess.gpg
echo "deb https://deb.goaccess.io/ $(lsb_release -sc) main" > /etc/apt/sources.list.d/goaccess.list
apt update
apt install goaccess

CentOS/RHEL

dnf install goaccess

Terminal-Modus

Interaktive Analyse

# Nginx
goaccess /var/log/nginx/access.log

# Apache
goaccess /var/log/apache2/access.log

# Mit Log-Format
goaccess /var/log/nginx/access.log --log-format=COMBINED

Tastaturkürzel

| Taste | Funktion | |-------|----------| | F1 | Hilfe | | q | Beenden | | Tab | Nächstes Panel | | Enter | Expand/Collapse | | j/k | Auf/Ab navigieren | | o | Details öffnen | | s | Sortieren | | / | Suchen |

Multiple Logs

# Mehrere Dateien
goaccess /var/log/nginx/access.log.1 /var/log/nginx/access.log

# Mit Wildcard
goaccess /var/log/nginx/access.log*

# Komprimierte Logs
zcat /var/log/nginx/access.log.*.gz | goaccess -

HTML-Report

Statischer Report

goaccess /var/log/nginx/access.log -o /var/www/html/report.html --log-format=COMBINED

Echtzeit-Report

goaccess /var/log/nginx/access.log -o /var/www/html/report.html --log-format=COMBINED --real-time-html

WebSocket (Echtzeit)

goaccess /var/log/nginx/access.log -o /var/www/html/report.html \
    --log-format=COMBINED \
    --real-time-html \
    --ws-url=wss://stats.example.de:7890 \
    --port=7890 \
    --daemonize

Log-Formate

Vordefinierte Formate

| Format | Verwendung | |--------|------------| | COMBINED | Apache/Nginx Combined | | COMMON | Apache Common | | VHOST_COMBINED | Mit Virtual Host | | W3C | W3C Extended | | CLOUFRONT | AWS CloudFront | | CADDY | Caddy JSON |

Nginx Combined

goaccess access.log --log-format=COMBINED
# Oder
goaccess access.log --log-format='%h %^[%d:%t %^] "%r" %s %b "%R" "%u"' \
    --date-format='%d/%b/%Y' \
    --time-format='%H:%M:%S'

Custom Nginx Format

# nginx.conf
log_format custom '$remote_addr - $remote_user [$time_local] '
                  '"$request" $status $body_bytes_sent '
                  '"$http_referer" "$http_user_agent" $request_time';
goaccess access.log --log-format='%h - %^ [%d:%t %^] "%r" %s %b "%R" "%u" %T'

Apache Custom

LogFormat "%h %l %u %t \"%r\" %>s %b \"%{Referer}i\" \"%{User-Agent}i\" %D" combined_with_time
goaccess access.log --log-format='%h %^[%d:%t %^] "%r" %s %b "%R" "%u" %D'

Konfigurationsdatei

~/.goaccessrc

# Log-Format
log-format %h %^[%d:%t %^] "%r" %s %b "%R" "%u"
date-format %d/%b/%Y
time-format %H:%M:%S

# Ausgabe
output /var/www/html/report.html
html-report-title "Server Statistics"

# Echtzeit
real-time-html true
ws-url wss://stats.example.de:7890
port 7890

# Optionen
ignore-crawlers true
exclude-ip 127.0.0.1
exclude-ip 10.0.0.0-10.255.255.255

# Geo-IP
geoip-database /usr/share/GeoIP/GeoLite2-City.mmdb

System-Konfiguration

# /etc/goaccess/goaccess.conf (falls vorhanden)

Filter und Ausschlüsse

IPs ausschließen

goaccess access.log --exclude-ip 127.0.0.1 --exclude-ip 192.168.1.0-192.168.1.255

Bots ignorieren

goaccess access.log --ignore-crawlers

Statische Dateien ausschließen

goaccess access.log --ignore-panel=STATIC_FILES

Zeitraum filtern

# Nur heute
goaccess access.log --ignore-panel=BY_DATE

# Mit awk vorfiltern
awk '$4 ~ /26\/Jan\/2026/' access.log | goaccess -

GeoIP

GeoLite2 installieren

# MaxMind GeoLite2 Database
apt install geoip-database

# Oder manuell herunterladen
wget https://download.maxmind.com/app/geoip_download?edition_id=GeoLite2-City&license_key=YOUR_KEY&suffix=tar.gz

Mit GeoIP nutzen

goaccess access.log --geoip-database=/usr/share/GeoIP/GeoLite2-City.mmdb

Panels

Verfügbare Panels

| Panel | Inhalt | |-------|--------| | VISITORS | Unique Visitors | | REQUESTS | Requested URLs | | STATIC_REQUESTS | Statische Dateien | | NOT_FOUND | 404 Errors | | HOSTS | Client IPs | | OS | Betriebssysteme | | BROWSERS | Browser | | VISIT_TIMES | Zeitverteilung | | VIRTUAL_HOSTS | Virtual Hosts | | REFERRERS | Referer | | REFERRING_SITES | Referring Sites | | KEYPHRASES | Suchbegriffe | | GEO_LOCATION | Länder | | STATUS_CODES | HTTP-Status |

Panels ein-/ausblenden

# Panel ausblenden
goaccess access.log --ignore-panel=KEYPHRASES --ignore-panel=STATIC_REQUESTS

# Nur bestimmte Panels
goaccess access.log --enable-panel=VISITORS --enable-panel=REQUESTS

Automatisierung

Cron-Job für täglichen Report

#!/bin/bash
# /usr/local/bin/generate-stats.sh

LOG=/var/log/nginx/access.log
OUTPUT=/var/www/html/stats/$(date +%Y-%m-%d).html

goaccess $LOG -o $OUTPUT --log-format=COMBINED

# Alte Reports löschen (älter als 30 Tage)
find /var/www/html/stats/ -name "*.html" -mtime +30 -delete
# Crontab
0 0 * * * /usr/local/bin/generate-stats.sh

Systemd-Service für Echtzeit

# /etc/systemd/system/goaccess.service

[Unit]
Description=GoAccess Real-Time Web Log Analyzer
After=network.target

[Service]
Type=simple
ExecStart=/usr/bin/goaccess /var/log/nginx/access.log \
    -o /var/www/html/report.html \
    --log-format=COMBINED \
    --real-time-html \
    --port=7890
Restart=always
RestartSec=3

[Install]
WantedBy=multi-user.target
systemctl enable goaccess
systemctl start goaccess

Nginx-Proxy für WebSocket

# /etc/nginx/sites-available/stats

server {
    listen 443 ssl;
    server_name stats.example.de;

    ssl_certificate /etc/letsencrypt/live/stats.example.de/fullchain.pem;
    ssl_certificate_key /etc/letsencrypt/live/stats.example.de/privkey.pem;

    # Authentifizierung
    auth_basic "Stats";
    auth_basic_user_file /etc/nginx/.htpasswd-stats;

    location / {
        root /var/www/html;
        index report.html;
    }

    location /ws {
        proxy_pass http://127.0.0.1:7890;
        proxy_http_version 1.1;
        proxy_set_header Upgrade $http_upgrade;
        proxy_set_header Connection "upgrade";
    }
}

Performance

Große Logs

# Mit Pipe (weniger RAM)
tail -n 100000 access.log | goaccess -

# Komprimierte Logs streamen
zcat access.log.*.gz | goaccess -

In-Memory Database

# Standard: On-Disk
goaccess access.log --db-path=/tmp/goaccess

# In-Memory (schneller, mehr RAM)
goaccess access.log --in-memory

Troubleshooting

Format-Probleme

# Log-Format debuggen
goaccess access.log --debug-file=/tmp/goaccess-debug.log

# Erste Zeile testen
head -1 access.log
# Format anpassen

Encoding-Probleme

# UTF-8 erzwingen
goaccess access.log --no-ip-validation

Leerer Report

# Log-Format stimmt nicht
# → --log-format=COMBINED versuchen
# → Custom Format prüfen

Zusammenfassung

| Befehl | Funktion | |--------|----------| | goaccess log | Terminal-Analyse | | goaccess -o file.html | HTML-Report | | --real-time-html | Echtzeit | | --log-format=COMBINED | Format setzen | | --ignore-crawlers | Bots ignorieren |

| Panel | Inhalt | |-------|--------| | VISITORS | Besucher | | REQUESTS | URLs | | NOT_FOUND | 404-Fehler | | HOSTS | Client-IPs | | GEO_LOCATION | Länder |

| Option | Wirkung | |--------|---------| | --exclude-ip | IP ausschließen | | --ignore-panel | Panel ausblenden | | --geoip-database | GeoIP aktivieren | | --db-path | Datenbank-Pfad |

Fazit

GoAccess ist das ideale Tool für schnelle Log-Analyse. Der Terminal-Modus eignet sich für Ad-hoc-Analysen, HTML-Reports für Dashboards. Die Echtzeit-Funktion mit WebSocket ist besonders nützlich für Live-Monitoring. Mit GeoIP werden geografische Insights möglich. Für große Log-Dateien ist GoAccess dank C-Implementierung extrem performant.