Splunk Search

Splunk search for multile counts

anlePRH
Observer

Hi all 

Trying to work on something which currently shows a bunch of IP hits and counts against it, the current output is the last 2 hours

Query:
index=source sourcetype="source" 
| stats count values(Hostname) by SourceIP
| sort by -count
| rename "count" to "Total count", "values(Hostname)" to "Hosts"

Output:
IP                                              Count
100.100.100.100               5

I want to add a new column called "Last30days" that looks at the IP address found in column 1 and a count search for the last 30 days, so like above but another column for the last 30days, final output below.

IP                                              Count                 Last30days
100.100.100.100               1                          10

tried various variaitions but can't get it to work

Labels (1)
0 Karma

gcusello
SplunkTrust
SplunkTrust

Hi @anlePRH ,

you could try something like this (to adapt to your requirement):

 

index=source sourcetype="source" 
| eval type=if(_time>now()-86400,"Today","Last30days")
| chart count OVER SourceIP BY type

 

Ciao.

Giuseppe

0 Karma
Career Survey
First 500 qualified respondents will receive a $20 gift card! Tell us about your professional Splunk journey.

Can’t make it to .conf25? Join us online!

Get Updates on the Splunk Community!

Can’t Make It to Boston? Stream .conf25 and Learn with Haya Husain

Boston may be buzzing this September with Splunk University and .conf25, but you don’t have to pack a bag to ...

Splunk Lantern’s Guide to The Most Popular .conf25 Sessions

Splunk Lantern is a Splunk customer success center that provides advice from Splunk experts on valuable data ...

Unlock What’s Next: The Splunk Cloud Platform at .conf25

In just a few days, Boston will be buzzing as the Splunk team and thousands of community members come together ...