Splunk Search

How to count each tupple values by day of the week

nishan_perera
Explorer

I got a query like this,

%asa deny OR denied | eval dest_port = if(isnum(dest_port),dest_port,00)| eval denyTuppleValue = src_ip."-".dest_ip."-".dest_port | stats values(denyTuppleValue),count(denyTuppleValue) by date_wday

Result

date_wday   values(denyTuppleValue) count(denyTuppleValue)
wednesday   xx.xxx.xxx.xxx-xxx.xx.xxx.x-xx   520
                     xx.xxx.xxx.xxx-xxx.xx.xxx.x-xx
                    xx.xxx.xxx.xxx-xxx.xx.xxx.x-xx
    thursday  xx.xxx.xxx.xxx-xxx.xx.xxx.x-xx   10
                   xx.xxx.xxx.xxx-xxx.xx.xxx.x-xx
                  xx.xxx.xxx.xxx-xxx.xx.xxx.x-xx

But i need to get the count for each denyTuppleValue not the count for the day. Which would look like

date_wday   values(denyTuppleValue) count(denyTuppleValue)
wednesday   xx.xxx.xxx.xxx-xxx.xx.xxx.x-xx   110
           xx.xxx.xxx.xxx-xxx.xx.xxx.x-xx      20
            xx.xxx.xxx.xxx-xxx.xx.xxx.x-xx     130

Any ideas would be much apprecieated.

Tags (3)
0 Karma
1 Solution

somesoni2
Revered Legend

Give this a try

 %asa deny OR denied | eval dest_port = if(isnum(dest_port),dest_port,00)| eval denyTuppleValue = src_ip."-".dest_ip."-".dest_port | stats count(denyTuppleValue) as count by date_wday,denyTuppleValue | stats values(denyTuppleValue) values(count) by date_wday

View solution in original post

somesoni2
Revered Legend

Give this a try

 %asa deny OR denied | eval dest_port = if(isnum(dest_port),dest_port,00)| eval denyTuppleValue = src_ip."-".dest_ip."-".dest_port | stats count(denyTuppleValue) as count by date_wday,denyTuppleValue | stats values(denyTuppleValue) values(count) by date_wday

nishan_perera
Explorer

this is also works, but you need to click the day inorder to go to the view i want. but yeah i can reuse your query to get the values i'm after and saving into a CSV file. thanks for the help

0 Karma

martin_mueller
SplunkTrust
SplunkTrust

You can even leave off the values(denyTuppleValue) when grouping by that very field.

0 Karma

nishan_perera
Explorer

true , i should get rid of that

0 Karma

musskopf
Builder

What happen if you change your search to:

%asa deny OR denied | eval dest_port = if(isnum(dest_port),dest_port,00)| eval denyTuppleValue = src_ip."-".dest_ip."-".dest_port | stats values(denyTuppleValue),count(denyTuppleValue) by date_wday, denyTuppleValue
0 Karma

nishan_perera
Explorer

this works , but the day get repeated for each value. but i think this is what i after. Cheers for the help

0 Karma
Get Updates on the Splunk Community!

Upcoming Webinar: Unmasking Insider Threats with Slunk Enterprise Security’s UEBA

Join us on Wed, Dec 10. at 10AM PST / 1PM EST for a live webinar and demo with Splunk experts! Discover how ...

.conf25 technical session recap of Observability for Gen AI: Monitoring LLM ...

If you’re unfamiliar, .conf is Splunk’s premier event where the Splunk community, customers, partners, and ...

A Season of Skills: New Splunk Courses to Light Up Your Learning Journey

There’s something special about this time of year—maybe it’s the glow of the holidays, maybe it’s the ...