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!

Index This | I am a number, but when you add ‘G’ to me, I go away. What number am I?

March 2024 Edition Hayyy Splunk Education Enthusiasts and the Eternally Curious!  We’re back with another ...

What’s New in Splunk App for PCI Compliance 5.3.1?

The Splunk App for PCI Compliance allows customers to extend the power of their existing Splunk solution with ...

Extending Observability Content to Splunk Cloud

Register to join us !   In this Extending Observability Content to Splunk Cloud Tech Talk, you'll see how to ...