Splunk Search

How to search for data for a specific day in GMT format

louisphilippela
New Member

I need to create a summary report of KPIs which are created by machines in 3 different timezones. My search head is in one timezone, so searching for yesterday on my search head will not get me the yesterday of all 3 different timezones, it will be shifted by couple hours.

How to tell Splunk I want to search for a specific day, but in GMT format, i.e. I want to search everything that happened on 2018-07-05 , regardless if it is PST, -0800 or EDT -0500.

Tags (1)
0 Karma
1 Solution

acharlieh
Influencer

So with the assumption that time is being extracted from your log entries and not being assigned automagically. And that your logs are written in the local time zone you can set your time picker wide enough to cover the day over all time zones, and use default extracted date time fields like date_mday to get down to only the desired day.

https://docs.splunk.com/Documentation/Splunk/7.0.3/Knowledge/Usedefaultfields

something like:

index=foo_* sourcetype=bar earliest=-2d@d latest=now 
| where date_mday=strftime(relative_time(now(),"-d@d"),"%d")

Now if your data does not have these fields or your data is recorded in UTC and not the local time zone, then you still want to search for a wide enough time range and you'd need some other method to looking up the offset of each group of hosts, and eliminating data that is not yesterday for those hosts.

View solution in original post

woodcock
Esteemed Legend

Go go Your Login/Name -> Preferences -> Time zone and set it to GMT and save. Logout and login and now all of your Timepicker selections (e.g. Yesterday) are normalized to GMT, including scheduled searches (until you change your Time zone value again). You might create a special user called userGMT that is only used for this type of reporting.

0 Karma

acharlieh
Influencer

So with the assumption that time is being extracted from your log entries and not being assigned automagically. And that your logs are written in the local time zone you can set your time picker wide enough to cover the day over all time zones, and use default extracted date time fields like date_mday to get down to only the desired day.

https://docs.splunk.com/Documentation/Splunk/7.0.3/Knowledge/Usedefaultfields

something like:

index=foo_* sourcetype=bar earliest=-2d@d latest=now 
| where date_mday=strftime(relative_time(now(),"-d@d"),"%d")

Now if your data does not have these fields or your data is recorded in UTC and not the local time zone, then you still want to search for a wide enough time range and you'd need some other method to looking up the offset of each group of hosts, and eliminating data that is not yesterday for those hosts.

louisphilippela
New Member

Thanks!

I think this is the most elegant and versatile way to do it in Splunk.

0 Karma

somesoni2
SplunkTrust
SplunkTrust

Can you post some sample raw logs?

0 Karma
Get Updates on the Splunk Community!

Welcome to the Splunk Community!

(view in My Videos) We're so glad you're here! The Splunk Community is place to connect, learn, give back, and ...

Tech Talk | Elevating Digital Service Excellence: The Synergy of Splunk RUM & APM

Elevating Digital Service Excellence: The Synergy of Real User Monitoring and Application Performance ...

Adoption of RUM and APM at Splunk

    Unleash the power of Splunk Observability   Watch Now In this can't miss Tech Talk! The Splunk Growth ...