Splunk Search

How to search for records between respective timezones?

ran_deep
New Member

We have logs from multiple region, but only want to report those between respective regions working hours.
Created following query which works fine when putting an absolute number, but doesn't filter by variables.

 

 

 

index=ovpm sourcetype=ovpm_global
| search "Service Name" = "WSB EXPRESS"
| eval region = case(substr(SYSTEMNAME, 1, 2) == "my", "AP", substr(SYSTEMNAME, 1, 2) == "cz", "EU", substr(SYSTEMNAME, 1, 2) == "us", "AM", true(), "Other")
| eval regionStartHour = tonumber(case(substr(SYSTEMNAME, 1, 2) == "my", 0, substr(SYSTEMNAME, 1, 2) == "cz", 8, substr(SYSTEMNAME, 1, 2) == "us", 16, true(), 0))
| eval regionEndHour = tonumber(case(substr(SYSTEMNAME, 1, 2) == "my", 8, substr(SYSTEMNAME, 1, 2) == "cz", 16, substr(SYSTEMNAME, 1, 2) == "us", 24, true(), 0))
| eval hr = strftime(_time, "%H") | search hr>=regionStartHour AND hr<=regionEndHour

 

 

 

 

Labels (2)
0 Karma

richgalloway
SplunkTrust
SplunkTrust

The search command cannot handle a field ("variable") name on both sides of the operator.  Use where, instead.

index=ovpm sourcetype=ovpm_global
| search "Service Name" = "WSB EXPRESS"
| eval region = case(substr(SYSTEMNAME, 1, 2) == "my", "AP", substr(SYSTEMNAME, 1, 2) == "cz", "EU", substr(SYSTEMNAME, 1, 2) == "us", "AM", true(), "Other")
| eval regionStartHour = tonumber(case(substr(SYSTEMNAME, 1, 2) == "my", 0, substr(SYSTEMNAME, 1, 2) == "cz", 8, substr(SYSTEMNAME, 1, 2) == "us", 16, true(), 0))
| eval regionEndHour = tonumber(case(substr(SYSTEMNAME, 1, 2) == "my", 8, substr(SYSTEMNAME, 1, 2) == "cz", 16, substr(SYSTEMNAME, 1, 2) == "us", 24, true(), 0))
| eval hr = strftime(_time, "%H") 
| where hr>=regionStartHour AND hr<=regionEndHour
---
If this reply helps you, Karma would be appreciated.
0 Karma
Get Updates on the Splunk Community!

UCC Framework: Discover Developer Toolkit for Building Technology Add-ons

The Next-Gen Toolkit for Splunk Technology Add-on Development The Universal Configuration Console (UCC) ...

.conf25 Community Recap

Hello Splunkers, And just like that, .conf25 is in the books! What an incredible few days — full of learning, ...

Splunk App Developers | .conf25 Recap & What’s Next

If you stopped by the Builder Bar at .conf25 this year, thank you! The retro tech beer garden vibes were ...