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
Get Updates on the Splunk Community!

Splunk Decoded: Service Maps vs Service Analyzer Tree View vs Flow Maps

It’s Monday morning, and your phone is buzzing with alert escalations – your customer-facing portal is running ...

What’s New in Splunk Observability – September 2025

What's NewWe are excited to announce the latest enhancements to Splunk Observability, designed to help ITOps ...

Fun with Regular Expression - multiples of nine

Fun with Regular Expression - multiples of nineThis challenge was first posted on Slack #regex channel ...