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.38k stars 1.11k forks source link

Error occurred at: src/parser.c - read_log - 2728 #1473

Closed swar0g closed 4 years ago

swar0g commented 5 years ago

Hi,

I am getting the following error trying to parse nginx error.log with goaccess:

# goaccess -f /var/log/nginx/error.log -p /etc/goaccess.conf

GoAccess - version 1.3 - Jun  5 2019 09:31:27
Config file: /etc/goaccess.conf

Fatal error has occurred
Error occurred at: src/parser.c - read_log - 2728
Unable to open the specified log file. No such file or directory

But the file definitely exists in the location:

# ls -al /var/log/nginx/error.log
-rw-r----- 1 nginx adm 20313 Jun  5 07:45 /var/log/nginx/error.log

Just in case, here is the goaccess config file:

time-format %H:%M:%S
date-format %Y/%m/%d
log-format %d %t %^, client: %h, server: %^, request: "%r", host: "%v", referrer: "%R"
config-dialog false
color-scheme 1
hl-header true
html-report-title Nginx error log statistics
no-color false
no-column-names false
no-progress false
with-mouse true
no-csv-summary false
all-static-files false
wukele commented 5 years ago

日志路径不存在导致

allinurl commented 5 years ago

Can you please try running goaccess without specifying the config file?

Panchom1977 commented 5 years ago

got the same with a big file and small one same just before analysis finished.

[fmillan@FMillanMacbookAir:access_log]$ goaccess intranet.log --log-format=VCOMBINED  --log-format="%v %h %^ %^[%d:%t %^] "%r " %s %b "%R" "%u" %^ %^ [%^/%D]" -e -d -q -a  -o uno.html --num-tests=0 -
Parsing... [1,174,758] [6,282/s]
GoAccess - version 1.3 - Jun 17 2019 02:48:47
Config file: No config file used

Fatal error has occurred
Error occurred at: src/parser.c - read_log - 2728
Unable to open the specified log file. No such file or directory

The file is there: Permissions:

access_log]$ ll intranet.log
-rw-r--r-- 1 username staff 523108731 Jun 21 16:55 intranet.log
allinurl commented 5 years ago

This seems like an isolated issue to your machine. Are you able to try reading the log on a different machine? Also, please make sure that you are using the right log format AND make sure you have access to write the file uno.html

Panchom1977 commented 5 years ago

I try in another server same problem same line the server was Centos 7 local OSX Mojave and got the same results in both I'll try it on another laptop

Panchom1977 commented 5 years ago

same with another OS, but, when i try custom on console it works OK

~$ goaccess -f Desktop/intranet.log   --log-format=VCOMBINED --log-format="%v %h %^ %^[%d:%t %^] "%r " %s %b "%R" "%u" %^ %^ [%^/%D]" -e -d -q -a -o uno.html --num-tests=0 -c
Parsing... [1,175,137] [3,329/s]
GoAccess - version 1.2 - Jun 19 2017 12:55:29
Config file: /etc/goaccess.conf

Fatal error has occurred
Error occured at: src/parser.c - read_log - 2669
Unable to open the specified log file. No such file or directory

see screenshot with console after it analize: Screenshot from 2019-06-22 15-31-19

Panchom1977 commented 5 years ago

I did another test on squid logs and worked ok with a similar log-format nginx custom:

caseworkpractice.intranet.facs.nsw.gov.au 172.26.72.26 - p_xie [21/Jun/2019:03:12:02 +1000] "GET /__data/assets/file/0010/345709/Contract-foster-carer-assessment.docx HTTP/1.1" 200 641/78311 "-" "Mozilla/5.0 (compatible; Funnelback)" "f5qohqbvnnietorlmdj42c2ghfij9i3dhf7t03g064fdbvo9k2gtdg6lu3m56d4q58lb467jl4fniv29l3udq0j0cs5621el744g7a0" close [-/0.000]

log-format %v %h %^ %^[%d:%t %^] %m %U %H %s %b "%R" "%u" %^ %^ [%^/%D]'

squid custom:

housinghub.intranet.facs.nsw.gov.au 172.26.72.26 - - [09/Jun/2019:03:48:03 +1000] "GET https://housinghub.intranet.facs.nsw.gov.au/training-and-systems/homes-support/source/homes-reports/pre-homes-corporate-reports/pre-homes-corporate-reports-prior-to-november-2011/estates-and-rents-statistical-report HTTP/1.1" 200 121406 "-" "Mozilla/5.0 (compatible; Funnelback)" TCP_MISS:FIRST_UP_PARENT 1090

log-format %v %h %^ %^[%d:%t %^] "%r" %s %b "%R" "%u" %^

allinurl commented 5 years ago

So is this working now?

Panchom1977 commented 5 years ago

when run the console it parse the file, but when i try to export to html does not work and failed at a few lines before the file ends

allinurl commented 5 years ago

if it fails right before it writes to it, it is likely due to some sort of permissions on that folder. who owns the goaccess process and the destination folder? can you run it as root?

Panchom1977 commented 5 years ago

run it as root as well in Linux server, run it with sudo in the mac run it as root in the Linux that I sent the image as the error says it looks like goaccess can't read the source file (the log file) I'll try to reinstall in the mac now and try again.

thejimbirch commented 4 years ago

I came across this error today. I believe it was because I was omitting the > before the HTML file name example.log > example.html. Once I added it, I could get passed the parse error.

allinurl commented 4 years ago

@thejimbirch Thanks for sharing that!

Closing this. Feel free to reopen it as needed.

onlime commented 2 years ago

just a small addition for those who struggle with this misleading error message. In my case it was because of a specified --db-path which was missing on filesystem.

Generating an example report for the last 30d:

$ grep example.com /var/www/example/logs/access.log | goaccess - --restore --persist -o /var/www/example/public_html/stats/index.html --db-path /var/www/example/public_html/stats/db/ --keep-last=30

If in this case /var/www/example/public_html/stats/db directory was missing, I run into above Unable to open the specified log file. No such file or directory error which was completely misleading as it referred to /etc/goaccess.conf which was always accessible under that user. Creating the db directory fixed it.

allinurl commented 2 years ago

@onlime Thanks for sharing that feedback. I've updated the error message to be more descriptive. It will be pushed out in the upcoming version. It reads now as:

Unable to open the specified db path/file '/tmp/test-path/'. No such file or directory
vszakats commented 2 years ago

In my case this exact error got triggered by setting anonymize-ip yes (instead of true or false) which caused goaccess to look for a file named yes, which did not exist. The patch above will make this clearer in the future. (It may also help to show an error if a boolean setting is set to an invalid value instead of regarding it as a filename.)

GoAccess - version 1.4 - Jul 23 2020 10:55:20
Config file: ./goaccess.conf

Fatal error has occurred
Error occurred at: src/parser.c - read_log - 2730
Unable to open the specified log file. No such file or directory
allinurl commented 2 years ago

@vszakats Thanks for sharing that info. Makes sense to show that if a boolean setting is set to an invalid value. Let me look into that as well.