tomcatweb-analytics

how to calculate the PV,ip,PU according to the tomcat log


how to calculate the PV,ip,PU according to the tomcat log?

I have export the tomcat log to db.

Something about the db structure can be found here.

For the ip I can use:

select count(distinct ip)...

But how about the pv and pu?

I have no idea,please do me a favor if you know.


Solution

  • Something like

    SELECT 
        COUNT(SELECT DISTINCT ip from tblName) AS IPs, 
        COUNT(SELECT DISTINCT uri from tblName) AS UniquePages, 
        COUNT(SELECT DISTINCT username from tblName) as UniqueVisitors from tblName;
    

    should work for you


    To limit what type of pages should be counted, add that to the sub-query

    SELECT 
        COUNT(SELECT DISTINCT ip from tblName) AS IPs, 
        COUNT(SELECT DISTINCT uri from tblName WHERE uri NOT LIKE '%.js' AND uri NOT LIKE '.css') AS UniquePages, 
        COUNT(SELECT DISTINCT username from tblName) as UniqueVisitors from tblName;