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.

Can’t make it to .conf25? Join us online!

Get Updates on the Splunk Community!

Take Action Automatically on Splunk Alerts with Red Hat Ansible Automation Platform

 Are you ready to revolutionize your IT operations? As digital transformation accelerates, the demand for ...

Calling All Security Pros: Ready to Race Through Boston?

Hey Splunkers, .conf25 is heading to Boston and we’re kicking things off with something bold, competitive, and ...

Beyond Detection: How Splunk and Cisco Integrated Security Platforms Transform ...

Financial services organizations face an impossible equation: maintain 99.9% uptime for mission-critical ...