I just created a new API for a custom service and I would like to track all unique IP's who are sending requests to my api in an extra awstats section but I don't know how to achieve that.
The api url: domain.com/api/
I would like to see 3 columns:
IP address | Number of requests from this IP | Last request date
Values should be from current month
Is that even possible in AWStats?
Can I count the unique requests from all IP's?
I figured out how I could achieve that with a bash command (but only for the current day).
This works exactly how I want it for AWStats and looks like this:
cat access.log | grep "/api/" | awk '{ print $1 " AGENT: " $12 " " $13 " " $14 " " $15 " " $16 }' | sort | uniq -c | sort -nr | head -n 100
Here's what I have so far in my awstats domain conf:
ExtraSectionName2="API Users"
ExtraSectionCodeFilter2="200"
ExtraSectionCondition2="URL,\/api\/.*"
ExtraSectionFirstColumnTitle2="IP"
ExtraSectionFirstColumnValues2="host"
ExtraSectionFirstColumnFormat2="%s"
ExtraSectionStatTypes2=HL
ExtraSectionAddAverageRow2=0
ExtraSectionAddSumRow2=1
MaxNbOfExtra2=50
MinHitExtra2=1
There is no much documentation for such niche cases, so I think someone else maybe have figured this out.
Thanks in advance!