AnswerBun.com

How to analyze multiple gz log files for Awstats?

Server Fault Asked on January 5, 2022

I am pretty new to awstats and have configured Awstats on my apache webserver to analyze nginx access logs(nginx webserver is for my django app), I am able to take the stats from LogFile=/var/log/nginx/access.log but how do I analyze multiple Logs that are gzip format. Such as access.log.1.gz…access.log.40.gz. I have a lot of logs to analyze.

2 Answers

Alternatively, you can use a real-time log analyzer, such as GoAccess. It's really fast and you don't need to unzip any log. apache & nginx

https://goaccess.io/

zcat -f access.log* | goaccess -a -s -b

OR

zcat access.log.*.gz | goaccess -a -s -b

Answered by Sanders12 on January 5, 2022

What you probably want to do here is to analyze all these logfiles once, then keep analyzing only the current logfiles from then on.

The simplest thing to do is unzip all those files into a single file, then have awstats run over it once, then point awstats at your access.log file from then on.

awstats normally has a script called logresolvemerge.pl, which can read the compressed files, and will merge them appropriately for awstats to do analsyis.

To merge all your existing ones, run

perl /usr/share/awstats/tools/logresolvemerge.pl /var/log/nginx/access.log* > /tmp/nginx.tmplog

This will probably take a while.

You can then have awstats run once over this file (set LogFile appropriately).

From then on, you should have awstats run over the most recent logfile - which is what your current configuration is doing.

Depending on how often you are running awstats vs rotating nginx logfiles, you may want to have it read both the current logfile and the previous one. (eg, if you rotate nginx logfiles every day at 12, but have awstats run every day at 1, then whenever awstats runs the logfile will only contain what's been written since the last rotation). You can use logresolvemerge.pl inside your LogFile command like this:

LogFile="/usr/share/awstats/tools/logresolvemerge.pl /var/log/nginx/access.log /var/log/nginx/access.log.1.gz |"

This tells awstats to run the logresolvemerge.pl command with the two logfiles as parameters, and awstats will read in the output of that script (that's what the pipe | does)

Answered by Daniel Lawson on January 5, 2022

Add your own answers!

Related Questions

ConvertToHTML converting wrong

1  Asked on February 9, 2021 by jonathan-davies

 

Shibboleth in sub-path URL

1  Asked on February 8, 2021 by j-b

 

How to resize docker volume after creation?

1  Asked on February 8, 2021 by gkman

 

Access Denied DHCP Tool

1  Asked on February 8, 2021 by drew-chapin

     

Custom file/folder permissions with S3FS?

1  Asked on February 8, 2021 by t-brian-jones

         

AWS RDS – Bottleneck

0  Asked on February 6, 2021 by tyralcori

     

Zabbix sensor ‘no data’

1  Asked on February 6, 2021 by jakub-kuszneruk

   

How to enable Ookla script to start automatically after server reboot?

1  Asked on February 5, 2021 by mangaldeep-dey

   

iptables port redirect with Docker

2  Asked on February 5, 2021 by jamescun

   

Where to securely deploy Citrix Netscaler?

1  Asked on February 4, 2021 by user54507

   

Kubernetes: How to mount volumes into Windows pods?

1  Asked on February 4, 2021 by rabejens

   

Ask a Question

Get help from others!

© 2023 AnswerBun.com. All rights reserved. Sites we Love: PCI Database, MenuIva, UKBizDB, Menu Kuliner, Sharing RPP, SolveDir