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!

Routing logs with Splunk OTel Collector for Kubernetes

The Splunk Distribution of the OpenTelemetry (OTel) Collector is a product that provides a way to ingest ...

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 ...