Splunk Search

How to compare new and existing data

mbasharat
Builder

Hi,

I have a field name VULN in index=ABC sourcetype=XYZ.

We need to know, if new VULN show up in 48hrs of data compared to 1 month ago. Basically, we need to see how many new VULNs are in data compared to last month and how many unique IPs are affected. 

Thanks in-advance!!!

Labels (4)
0 Karma
1 Solution

gcusello
SplunkTrust
SplunkTrust

Hi @mbasharat,

sorry there was a mistyping, please try this:

index=ABC sourcetype=XYZ VULN=* earliest=-mon latest=now
| eval period=if(now()-_time>3600*48,"Before","Last_48_hours")
| stats dc(period) AS dc_period values(period) AS period BY VULN
| where dc_period=1 AND period="Last_48_hours"
| table VULN

There was a wrong less char "-".

Ciao.

Giuseppe

View solution in original post

0 Karma

gcusello
SplunkTrust
SplunkTrust

Hi @mbasharat,

you could try something like this:

index=ABC sourcetype=XYZ VULN=* earliest=-mon latest=now
| eval period=if(now()-_time>-3600*48,"Before","Last_48_hours")
| stats dc(period) AS dc_period values(period) AS period BY VULN
| where dc_period=1 AND period="Last_48_hours"
| table VULN

In this way you'll have the VULNs present in the last 48 hours but not in the last month.

Ciao.

Giuseppe

0 Karma

mbasharat
Builder

Hi @gcusello 

 

I tried and I am getting no results for this. Then I removed Last_48_hrs and everything is falling under "Before"

0 Karma

gcusello
SplunkTrust
SplunkTrust

Hi @mbasharat,

sorry there was a mistyping, please try this:

index=ABC sourcetype=XYZ VULN=* earliest=-mon latest=now
| eval period=if(now()-_time>3600*48,"Before","Last_48_hours")
| stats dc(period) AS dc_period values(period) AS period BY VULN
| where dc_period=1 AND period="Last_48_hours"
| table VULN

There was a wrong less char "-".

Ciao.

Giuseppe

0 Karma

gcusello
SplunkTrust
SplunkTrust

Hi @mbasharat,

good for you, see next time!

Ciao and happy splunking

Giuseppe

P.S.: Karma Points are appreciated 😉

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