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!

Join Us for Splunk University and Get Your Bootcamp Game On!

If you know, you know! Splunk University is the vibe this summer so register today for bootcamps galore ...

.conf24 | Learning Tracks for Security, Observability, Platform, and Developers!

.conf24 is taking place at The Venetian in Las Vegas from June 11 - 14. Continue reading to learn about the ...

Announcing Scheduled Export GA for Dashboard Studio

We're excited to announce the general availability of Scheduled Export for Dashboard Studio. Starting in ...