Splunk Search

How to use two queries in one?

tahasefiani
Explorer

Hello,

Today i have this query in my dashboard :

| loadjob savedsearch="myquery"
 |eval FromDate = "2020-01-23"
 |eval ToDate = "2020-01-23"
 | eval ToDateexpir = strptime("2020-01-23", "%Y-%m-%d")
 | eval expiring = ToDate + 86400*4
 | eval expiring = strftime(expiring, "%Y-%m-%d")
 | where (strftime(_time, "%Y-%m-%d") >= FromDate) AND (strftime(_time, "%Y-%m-%d") <= ToDate)
 | stats count(eval(if(MESSAGE="show",STEP,NULL))) AS showed,
 count(eval(if(MESSAGE="send",STEP,NULL))) AS sent,
 count(eval(if(MESSAGE="delete",STEP,NULL))) AS deleted by client |where showed>0
 |stats sum(showed) AS showed,sum(sent) AS sent,sum(deleted) AS deleted
 | eval AVG= round(((showed - (sent+deleted))/showed*100),2)." %"

I want to keep the same query and logic, but for the calculation of the fields "sent" i want it to be from "FromDate" to "expiring"
Thank you 🙂

Tags (2)
0 Karma

to4kawa
Ultra Champion
| where (strftime(_time, "%Y-%m-%d") >= FromDate) AND (strftime(_time, "%Y-%m-%d") <= ToDate)

Is this query really work?

0 Karma

tahasefiani
Explorer

| loadjob savedsearch="myquery"
|eval FromDate = "2020-01-23"
|eval ToDate = "2020-01-23"
| eval ToDateexpir = strptime("2020-01-23", "%Y-%m-%d")
| eval expiring = ToDate + 86400*4
| eval expiring = strftime(expiring, "%Y-%m-%d")
| where (strftime(_time, "%Y-%m-%d") >= FromDate) AND (strftime(_time, "%Y-%m-%d") <= ToDate)
| stats count(eval(if(MESSAGE="show",STEP,NULL))) AS showed,
count(eval(if(MESSAGE="send",STEP,NULL))) AS sent,
count(eval(if(MESSAGE="delete",STEP,NULL))) AS deleted by client |where showed>0
|stats sum(showed) AS showed,sum(sent) AS sent,sum(deleted) AS deleted
| eval AVG= round(((showed - (sent+deleted))/showed*100),2)." %"

0 Karma
Get Updates on the Splunk Community!

Index This | What is broken 80% of the time by February?

December 2025 Edition   Hayyy Splunk Education Enthusiasts and the Eternally Curious!    We’re back with this ...

Unlock Faster Time-to-Value on Edge and Ingest Processor with New SPL2 Pipeline ...

Hello Splunk Community,   We're thrilled to share an exciting update that will help you manage your data more ...

Splunk MCP & Agentic AI: Machine Data Without Limits

Discover how the Splunk Model Context Protocol (MCP) Server can revolutionize the way your organization uses ...