allinurl / goaccess

GoAccess is a real-time web log analyzer and interactive viewer that runs in a terminal in *nix systems or through your browser.
https://goaccess.io
MIT License
18.12k stars 1.1k forks source link

Docker - Fatal error when starting container #2023

Closed tuxrinku closed 3 years ago

tuxrinku commented 3 years ago

When I start the container, it doesn't show any error related about the parsing itself, but in the end I have the following : [SETTING UP STORAGE goaccess] {0} @ {0/s} GoAccess - version 1.4.5 - Feb 3 2021 00:47:46 Config file: /goaccess/goaccess.conf Fatal error has occurred Error occurred at: src/parser.c - set_initial_persisted_data - 3255 Unable to fread the specified log file 'goaccess'

My access.log file is in the following format : my.host.net 111.111.111.111 - - [08/Feb/2021:14:36:27 +0000] "GET / HTTP/2.0" 302 0 "-" "Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:85.0) Gecko/20100101 Firefox/85.0"

Here's my docker command: docker run -d --name goaccess --restart=always \ -p 7890:7890 \ -v /home/rinku/docker/goaccess_docker:/goaccess \ -v /home/rinku/docker/nginx_proxy_conf/log/access.log:/goaccess/access.log \ allinurl/goaccess \ goaccess --no-global-config --config-file=/goaccess/goaccess.conf

And my goaccess.conf file : log-format %v %h %^[%d:%t %^] "%r" %s %b "%R" "%u" %T %^ date-format %d/%b/%Y time-format %T log-file /goaccess/access.log output /goaccess/index.html real-time-html true

allinurl commented 3 years ago

Sounds like it may not be a valid path. Can I ask you to try generating the report as:

cat access.log | sudo docker run -p 7890:7890 --rm -i -e LANG=$LANG allinurl/goaccess -a -o html --log-format='%v %h %^[%d:%t %^] "%r" %s %b "%R" "%u" %T %^' --date-format=%d/%b/%Y --time-format=%T --real-time-html - > report.html
tuxrinku commented 3 years ago

It works perfectly that way. Thank you

allinurl commented 3 years ago

Glad to hear that. Closing this. Feel free to reopen it if needed.

el95149 commented 3 years ago

Hi there, I've just started facing the same error today, using a docker compose setup (in a swarm), which I've been successfully using in production for at least one year.

The only thing I tried doing today was update to the latest Goaccess image (redeploying my stack), and since then it's gone belly up.

Here's my docker compose file (minus some Traefik config):

version: "3.7"

services:
  #  An nginx server is required, to serve the HTML report page generated by Goaccess
  nginx:
    image: nginx:1.18.0-alpine
    networks:
      - proxy
    volumes:
      # Pick up the HTML report generated by Goaccess
      - "${DIRECTORY}/html:/usr/share/nginx/html"
      - "/var/run/docker.sock:/tmp/docker.sock:ro"
  goaccess:
    # digest: 6dd53b48c8962ffd430b2b2a261b805bab0307f2f8b4a727db11cbe2881bb1f0
    image: allinurl/goaccess:latest
    networks:
      - proxy
    environment:
      - TZ=Europe/Athens
    volumes:
      - "${DIRECTORY}:/goaccess"
      # This is where the HTML report that gets picked up by nginx goes
      - "${DIRECTORY}/html/index.html:/goaccess/index.html"
      # Traefik access log to be processed
      - "${ACCESS_LOG}:/goaccess/access.log"
    command: ["goaccess", "--no-global-config", "--config-file=/goaccess/goaccess.conf",
              "--ws-url=wss://ws.${HOST_NAME}:443"]

networks:
  proxy:
    external: true

And here are the pertinent bits of my Goaccess conf file (everything else is as per the default config "template"):

log-file /goaccess/access.log
output /goaccess/index.html
real-time-html true
daemonize false
#log-format COMMON
log-format %h %^[%d:%t %^] "%r" %s %b "%R" "%u" %^ "%v" %^ %T
time-format %T
date-format %d/%b/%Y

The deployment command for the above stack is:

env DIRECTORY="/mnt/data/goaccess" ACCESS_LOG="/mnt/data/traefik/log/access.log" HOST_NAME="....." docker stack deploy -c docker-compose.yml goaccess

Re-iterating the error, for the sake of completeness:

[SETTING UP STORAGE goaccess] {0} @ {0/s}
GoAccess - version 1.4.5 - Feb 11 2021 04:10:18
Config file: /goaccess/goaccess.conf
Fatal error has occurred
Error occurred at: src/parser.c - set_initial_persisted_data - 3255
Unable to fread the specified log file 'goaccess'

Any help would be appreciated, cheers!

allinurl commented 3 years ago

@el95149 please take a look at my previous post on how to run it. The docker file has changed in the last few releases.

el95149 commented 3 years ago

After a bit of tinkering, and based on your updated command above, this eventually did the trick:

.....
    volumes:
      - "${DIRECTORY}:/goaccess"
      # This is where the HTML report that gets picked up by nginx goes
      - "${DIRECTORY}/html/index.html:/index.html"
      # Traefik access log to be processed
      - "${ACCESS_LOG}:/access.log"
    command: ["access.log", "-a", "-o html", "--no-global-config", "--config-file=/goaccess/goaccess.conf",
              "--ws-url=wss://ws.${HOST_NAME}:443", "-"]
....

combined with this:

log-file /access.log
output /index.html
....

It's working like a charm now, thanks a bunch!

allinurl commented 3 years ago

@el95149 Glad to hear it works now. Feel free to report any other issues you may find.

holiday25 commented 4 months ago

I am running goaccess with ansible this how i mount volumes volumes:

allinurl commented 4 months ago

@holiday25 It seems like there might be an issue with how you're specifying the log file path in your Ansible config. Ensure that this path actually exists on your system and that the file gitlab_access.log is present within that directory. Also, ensure that the container has the necessary permissions to read the log file.