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!

Enter the Agentic Era with Splunk AI Assistant for SPL 1.4

  &#x1f680; Your data just got a serious AI upgrade — are you ready? Say hello to the Agentic Era with the ...

Stronger Security with Federated Search for S3, GCP SQL & Australian Threat ...

Splunk Lantern is a Splunk customer success center that provides advice from Splunk experts on valuable data ...

Accelerating Observability as Code with the Splunk AI Assistant

We’ve seen in previous posts what Observability as Code (OaC) is and how it’s now essential for managing ...