Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Expose all nginx access logs for GoAccess consumption #8

Open
twopercent opened this issue Jun 13, 2022 · 1 comment
Open

Expose all nginx access logs for GoAccess consumption #8

twopercent opened this issue Jun 13, 2022 · 1 comment

Comments

@twopercent
Copy link

Perhaps with a flag, a user could specify their intention to load the nginx logs into goaccess.
The pan-collect-logs.sh script could create an additional directory: logs/${SITENAME}/access_logs. After the rsync action the script could extract all nginx-access-log-{date}.gz files and place them into the access logs directory. Then the user only needs to run goaccess against that directory to ingest all available logs.

@twopercent
Copy link
Author

twopercent commented Jun 13, 2022

Here is my stab at it. I execute this script from within the logs/${SITENAME} directory

#!/bin/bash

if [ ! -d "access_logs" ]; then
  mkdir access_logs
fi

for server in $(ls |grep appserver_)
do
  for log in $(ls $server/logs/nginx |grep nginx-access.log-)
  do
    gzip -dk $server/logs/nginx/$log
    file=$(echo $log |cut -f 1-2 -d '.')
    mv $server/logs/nginx/$file access_logs/$server-$file
  done
done

I didn't include the current access log that is not compressed.
The goaccess command could be added as well.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant