Join GitHub today
GitHub is home to over 31 million developers working together to host and review code, manage projects, and build software together.Sign up
real-time with multiple log #600
Is there a way to have the real-time mode with a log in multiple files (log rotation) like access.log.0, access.log.1, ...? I use nginx, but it is not specific to it and should be a common problem.
It is easy without real-time as we can just aggregate all log and run the program on it.
The problem is that if I just use -f access.log.0 I do not have my old data (and not sure that when the log rotation is done it will keep the current data?). Or if I restart goaccess I would loose the old data.
One way I found was to load the aggregation of the old files with --keep-db, and then start goaccess with --read-from-disk and --keep-db but if I restart it multiple times the same day, the data from acess.log.0 is -re-read and kept multiple times. So still not a solution.
Another way would be to have an external program always running which takes all old files and tail the current one. But it seems a little over-kill.
Currently there's no way to have the real-time functionality when piping multiple log files. This will be addressed in #428 and #459. As you said, a workaround would be to tail multiple logs and append them to a new log file and feed that to GoAccess.
However, just to clarify log rotation, GoAccess will display the the contents of the new log file as in the case of
Ok ! Waiting for it.
For people with the same problem, I found a workaround in the mean time. My service script contains a first line for parsing the old files and save it to the database, and the second launches goaccess in real time :
With this method I can restart the service (or reboot) without double parsing and the real-time is working with the old data too.
I've pushed a commit that enables the ability to output live stats from a stream or an unclosed STDIN, i.e., tail -f as well as parsing multiple logs in live mode:
It also opens the possibility for live data filtering from the pipe such as:
One thing to note is that tail -f will keep the pipe opened even when goaccess has already exited. For instance,
Feel free to build from master to test this out, otherwise it will be pushed out in the upcoming release. Thanks.