Splunk Search

How do I make a column chart that compares the result from last year with this year by month?

MCH2018
Explorer

Hi everyone,

I would like to make a chart that compares the result from last year with this year by month.

alt text

This is my search :

...| dedup CaseNumber | search ProductName=* IsDeleted=False  AccountName="*" CaseRecordTypeName=Standard | eval CreatedDateUNIX=strptime(CreatedDate,"%Y-%m-%d %H:%M:%S") | eval _time=CreatedDateUNIX  | where _time>=strptime("2017-01-01 00:00:00","%Y-%m-%d %H:%M:%S") AND _time<=strptime("2017-12-31 23:59:59","%Y-%m-%d %H:%M:%S") | timechart span=1mon count as 2017 | appendcols [dedup CaseNumber | search ProductName=* IsDeleted=False  AccountName="*" CaseRecordTypeName=Standard | eval CreatedDateUNIX=strptime(CreatedDate,"%Y-%m-%d %H:%M:%S") | eval _time=CreatedDateUNIX | eval date=_time | eval today=round(relative_time(now(),"@y")) | where date>today | timechart span=1mon count as 2018]

Both searches work well separately, but when i try to combine them, I only see the 2017 data.

If someone could help me, that would be great. I'll be grateful.

0 Karma

woodcock
Esteemed Legend

Did you get a solution, @MCH2018?

0 Karma

woodcock
Esteemed Legend

You need the timewrap span=1m command, see documentation here:
https://docs.splunk.com/Documentation/Splunk/latest/SearchReference/Timewrap

0 Karma

efavreau
Motivator

I agree. Timewrap is the shortcut needed here. If the op wants to see an example of that, look here: https://answers.splunk.com/answers/145458/can-timewrap-be-utilized-to-only-use-weekdays.html

###

If this reply helps you, an upvote would be appreciated.
0 Karma

cmerriman
Super Champion

what if you just did ...| dedup CaseNumber | search ProductName=* IsDeleted=False AccountName="*" CaseRecordTypeName=Standard | eval CreatedDateUNIX=strptime(CreatedDate,"%Y-%m-%d %H:%M:%S")| eval _time=CreatedDateUNIX|timechart span=1mon count|timewrap 1y and maybe any other filtering you might want to get last year to now. i see you have that in the first search to grab 2017 and you have a different filter to grab 2018.

0 Karma
Get Updates on the Splunk Community!

Introducing the 2024 SplunkTrust!

Hello, Splunk Community! We are beyond thrilled to announce our newest group of SplunkTrust members!  The ...

Introducing the 2024 Splunk MVPs!

We are excited to announce the 2024 cohort of the Splunk MVP program. Splunk MVPs are passionate members of ...

Splunk Custom Visualizations App End of Life

The Splunk Custom Visualizations apps End of Life for SimpleXML will reach end of support on Dec 21, 2024, ...