Score:0

AWStats Extra Section: Show all unique IP requests for specific URL

jp flag

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/

  1. I would like to see 3 columns: IP address | Number of requests from this IP | Last request date

  2. 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!

mangohost

Post an answer

Most people don’t grasp that asking a lot of questions unlocks learning and improves interpersonal bonding. In Alison’s studies, for example, though people could accurately recall how many questions had been asked in their conversations, they didn’t intuit the link between questions and liking. Across four studies, in which participants were engaged in conversations themselves or read transcripts of others’ conversations, people tended not to realize that question asking would influence—or had influenced—the level of amity between the conversationalists.