Splunk Search

How do I localize date_mday?

zzztimbo
Engager

When I use chart using date_mday as a parameter, it is in GMT. Is there any way to make this the date for my local time zone?

Tags (2)

Lowell
Super Champion

I don't think you can, at least not easily. The problem is that date_mday and all the other date_* fields are determined at index time. So these are static values that cannot be shifted to adjust for timezone at search time.

You can however build your own field that contains the day with an eval command like this:

 ... | eval mday=strftime("%d", _time) | chart ... by mday

So from there you will probably get the exact same value that date_mday already contains, so what you'll have to do is find the correct timezone offset and adjust for that manually. For example, if are 1 hour off GMT, then you could use:

 ... | eval mday=strftime("%d", _time+3600)

If you have different servers in different timezones that this gets more complicated. You may be able to leverage the fact that date_zone contains the timezone offset in minutes within your timezone calculations. (It also contains the word "local", so'll have to filter that out, something like:

 ... | eval tz_offset_secs=if(date_zone=="local", 0, date_zone*60)


Related question:

0 Karma

gkanapathy
Splunk Employee
Splunk Employee

Just to be accurate, if date_zone is local, then the offset you use should be the offset of the indexer's local time zone. This would only be zero if the indexer was running on UTC/GMT, but is fixed and known for any given indexer.

Get Updates on the Splunk Community!

.conf24 | Registration Open!

Hello, hello! I come bearing good news: Registration for .conf24 is now open!   conf is Splunk’s rad annual ...

ICYMI - Check out the latest releases of Splunk Edge Processor

Splunk is pleased to announce the latest enhancements to Splunk Edge Processor.  HEC Receiver authorization ...

Introducing the 2024 SplunkTrust!

Hello, Splunk Community! We are beyond thrilled to announce our newest group of SplunkTrust members!  The ...