Splunk Search

appending 2 searches + date format is lost YYYY-MM becomes YYYY

HattrickNZ
Motivator

I have 2 searches:

search1 and search2

search 1 gives :

_time   kpi1    kpi2    kpi3 kpi4
2016-01 493.26  636.06  56.322  1129.32

search 2 gives :

_time   kpi1    kpi2    kpi3 kpi4
2017-01 193.26  44.06   34.322  239.32

I combine them with the append (e.g. search 1 ... | append [ search2 ...])

 _time    kpi1    kpi2    kpi3 kpi4
2016    470.55  277.07  37.060  747.62
2017    193.26  44.06   34.322  239.32

but not the time format loses the month (e.g 2017-01 becomes 2017)

How do I get it to hold on to the month?

 _time    kpi1    kpi2    kpi3 kpi4
2016-01 470.55  277.07  37.060  747.62
2017-01 193.26  44.06   34.322  239.32
Tags (2)
0 Karma
1 Solution

DalJeanis
Legend

If you left _time in its original, epoch format in both searches, and each search is returning only a single record, then the interface may just be guessing that you only care about the year. Tell it what you want.

| eval _time=strftime(_time,"%Y-%m")

See somesoni2's answer below, which leaves the underlying field in epoch format and probably should be the general way you do this stuff.

View solution in original post

DalJeanis
Legend

If you left _time in its original, epoch format in both searches, and each search is returning only a single record, then the interface may just be guessing that you only care about the year. Tell it what you want.

| eval _time=strftime(_time,"%Y-%m")

See somesoni2's answer below, which leaves the underlying field in epoch format and probably should be the general way you do this stuff.

somesoni2
Revered Legend

Or use the fieldformat command ( | fieldformat_time=strftime(_time,"%Y-%m") ).

HattrickNZ
Motivator

tks @DalJeanis, that worked.

0 Karma

DalJeanis
Legend

Awesome! Good to hear.

0 Karma

cmerriman
Super Champion

can you try to put _time into epoch on both searches and then change the format to YYYY-MM after the append to see if that works?

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