Splunk Search

How to add custom time range to my xyseries search?

cvalenti
Explorer

I have this search:

 index="tticket_contact_request"
    |eval date=strftime(_time, "%Y-%m")
    |stats count by des_service,des_problem,date
    |eval service_problem= des_service.",".des_problem 
    |xyseries grouped=false service_problem,date,count
    |sort service_problem
    |rename service_problem as "des_service,des_problem"
    |fillnull value=0
    |addcoltotals label=Total
    |fillnull value="total,total" "des_service,des_problem"

and I would like to add something like this:

 | where _time >= relative_time(now(),"-1mon@mon") AND _time < relative_time(now(),"@mon")

to retrieve only data from last month. Any tips? I'll accept performance advice as well

0 Karma
1 Solution

somesoni2
SplunkTrust
SplunkTrust

Try this

index="tticket_contact_request" earliest=-1mon@mon latest=@mon
     |eval date=strftime(_time, "%Y-%m")
     |stats count by des_service,des_problem,date
     |eval service_problem= des_service.",".des_problem 
     |xyseries grouped=false service_problem,date,count
     |sort service_problem
     |rename service_problem as "des_service,des_problem"
     |fillnull value=0
     |addcoltotals label=Total
     |fillnull value="total,total" "des_service,des_problem"

View solution in original post

somesoni2
SplunkTrust
SplunkTrust

Try this

index="tticket_contact_request" earliest=-1mon@mon latest=@mon
     |eval date=strftime(_time, "%Y-%m")
     |stats count by des_service,des_problem,date
     |eval service_problem= des_service.",".des_problem 
     |xyseries grouped=false service_problem,date,count
     |sort service_problem
     |rename service_problem as "des_service,des_problem"
     |fillnull value=0
     |addcoltotals label=Total
     |fillnull value="total,total" "des_service,des_problem"

cvalenti
Explorer

thanks @somesoni2. I was overthinking a simple problem.

0 Karma

woodcock
Esteemed Legend

Give us some sample events.

0 Karma

cvalenti
Explorer

an example:

des_service,des_problem|2017-04|2017-05
database,error|15|16
app,error|7|10

I'll like to show only the summarization from last month, in case '2017-05' to send in a csv report

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