IIS logparser – Count distinct from cs-uri-query

iislogparsersql

I need to count how many DIFFERENT MAC´s that have accessed my IIS webserver and have a state value of 1.

The "MAC" adress and the "state" value are in the actual query (cs-uri-query)

So the log can look like this (only the cs-uri-query field are shown):

mac=00-20-c2-41-7e-b6&state=1&div=10
mac=00-20-c2-41-7e-b6&state=1&div=10
mac=00-20-c2-41-7e-b6&state=0&div=10
mac=00-10-c3-41-7e-b7&state=1&div=10

In this case the LogAnalyzer should count=2. 2 times have DIFFERENT MAC´s visited with the state of 1.

Can someone help me with the SLQ to use with LogAnalyzer?

Best Answer

Try this out:

select count(distinct extract_value(cs-uri-query, 'mac'))
from *.log
where extract_value(cs-uri-query, 'state') = '1'

You might hve to adjust field names depending on your log format.