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!

New in Observability Cloud - Explicit Bucket Histograms

Splunk introduces native support for histograms as a metric data type within Observability Cloud with Explicit ...

Updated Team Landing Page in Splunk Observability

We’re making some changes to the team landing page in Splunk Observability, based on your feedback. The ...

New! Splunk Observability Search Enhancements for Splunk APM Services/Traces and ...

Regardless of where you are in Splunk Observability, you can search for relevant APM targets including service ...