Splunk Search

generate daily report on date field in data

alexm2a
Engager

Hi there,

I have some data like this

activity_id:     1131c134-d771-41e7-918d-d42772fc1316   
     date_time:  2018-02-13T08:21:40.682844+00:00   
     env:    prod   
     event_data:    {   [-] 
         channel:    1124   
         day:    2018-02-18 
         eventId:    97356218   
         streamEndDateTime:  1518974100000  
         streamStartDateTime:    1518965640000  
    }   
     event_name:     update.event
     timestamp:  1518510100682  

And I would like Splunk to generate a report each day at midnight based on the next 2 days from the 'event_data.day' value. For example if today is 2018-02-17, the report would check

event_name="update.event"  event_data.day="2018-02-17" OR event_data.day="2018-02-18"

The next day the report would check for

event_name="update.event"  event_data.day="2018-02-18" OR event_data.day="2018-02-19"

etc.

Any help would be greatly appreciated.

0 Karma
1 Solution

HiroshiSatoh
Champion

Try this!

event_name="update.event"  [search |noop|stats count as event_data.day
|eval event_data.day=strftime(now(),"%Y-%m-%d")+" "+strftime(relative_time(now(),"+1d@d"),"%Y-%m-%d")
|makemv event_data.day
|mvexpand event_data.day]

View solution in original post

HiroshiSatoh
Champion

Try this!

event_name="update.event"  [search |noop|stats count as event_data.day
|eval event_data.day=strftime(now(),"%Y-%m-%d")+" "+strftime(relative_time(now(),"+1d@d"),"%Y-%m-%d")
|makemv event_data.day
|mvexpand event_data.day]

mayurr98
Super Champion

hey @hiroshiSatoh

I was just wondering why you have used |noop|stats count as event_data.day?
If you do not use that then you will not get an answer? Just trying to understand your query.
Also event_data.day=strftime(now(),"%Y-%m-%d")+" "+strftime(relative_time(now(),"+1d@d"),"%Y-%m-%d" will give you today and tomorrow date right?

0 Karma

alexm2a
Engager

Brilliant! Thank you!

0 Karma
Get Updates on the Splunk Community!

Splunk Enterprise Security 8.x: The Essential Upgrade for Threat Detection, ...

 Prepare to elevate your security operations with the powerful upgrade to Splunk Enterprise Security 8.x! This ...

Get Early Access to AI Playbook Authoring: Apply for the Alpha Private Preview ...

Passionate about security automation? Apply now to our AI Playbook Authoring Alpha private preview ...

Reduce and Transform Your Firewall Data with Splunk Data Management

Managing high-volume firewall data has always been a challenge. Noisy events and verbose traffic logs often ...