Splunk Enterprise

How to combine queries to use for alert?

vishwa
Path Finder

I have 3 queries , i want to combine to one query so that i can use it for alert

Query1:
index=error-data  sourcetype=error:logs  source=https://error:appliocation.logs
"logs started"   "tarnsaction recevied"
[|inputlookup append=t  errorlogs.csv where error=2
|fields host
|format]
|stats count as "initial error logs "

Query2:
index=error-data  sourcetype=error:logs  source=https://error:appliocation.logs
" timeouterror" AND "failed logs confirmed "
[|inputlookup append=t  errorlogs.csv where error=2
|fields host
|format]
|stats count as "logs in transactions "

Query3:
index=error-data  sourcetype=error:logs  source=https://error:appliocation.logs
" application logs continuted"
[|inputlookup append=t  errorlogs.csv where error=2
|fields host
|format]
|stats count as "total failed"

Labels (1)
Tags (2)
0 Karma

vishwa
Path Finder

Hi @richgalloway .

, thank you it worked.

I have one more question is there any way I can restrict events in splunk

For example From the above query if I get 10 same logs in 1 hour

How can I write a query to fetch

only 5 records in 1 hour

0 Karma

richgalloway
SplunkTrust
SplunkTrust

I don't know how to do that.

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

richgalloway
SplunkTrust
SplunkTrust

See if this helps

index=error-data  sourcetype=error:logs  source=https://error:appliocation.logs
("logs started"   "tarnsaction recevied") OR (" timeouterror" AND "failed logs confirmed ") OR (" application logs continuted")
[|inputlookup append=t  errorlogs.csv where error=2
|fields host
|format]
| eval initialError=if(searchmatch("logs started" AND "tarnsaction recevied"),1,0)
| eval transLogs=if(searchmatch(" timeouterror" AND "failed logs confirmed "),1, 0)
| eval Failed=if(searchmatch(" application logs continuted"), 1,0)
|stats count(eval(initialError=1)) as "initial error logs ", count(eval(transLogs=1) as "logs in transactions", count(eval(failed=1) as "total failed"
---
If this reply helps you, Karma would be appreciated.
0 Karma
Career Survey
First 500 qualified respondents will receive a $20 gift card! Tell us about your professional Splunk journey.
Get Updates on the Splunk Community!

Introduction to Splunk AI

How are you using AI in Splunk? Whether you see AI as a threat or opportunity, AI is here to stay. Lucky for ...

Splunk + ThousandEyes: Correlate frontend, app, and network data to troubleshoot ...

Are you tired of troubleshooting delays caused by siloed frontend, application, and network data? We've got a ...

Maximizing the Value of Splunk ES 8.x

Splunk Enterprise Security (ES) continues to be a leader in the Gartner Magic Quadrant, reflecting its pivotal ...