Alerting

How to create a triggering email alert to include log files content in the email?

rchittip
Path Finder

Hi,
I would like to set up email alerts for the log content of files. If file stuck in the directory, would like to send alert with filename to the team. Can we achieve this in splunk. Below are the logs.

[2018/02/05 07:26][Warning]:[3PL] : File EDIDATA7129 is stuck in queue for more than 4 hrs. FileName: **D:\EDI\3PL\Inbound\EDIDATA7129**
[2018/02/05 07:26][Warning]:[3PL] : File EDIDATA6077 is stuck in queue for more than 4 hrs. FileName: **D:\EDI\3PL\Inbound\EDIDATA6077**
[2018/02/05 07:26][Warning]:[3PL] : File EDIDATA6074 is stuck in queue for more than 4 hrs. FileName: **D:\EDI\3PL\Inbound\EDIDATA6074**

Thanks,
Ramu Chittiprolu

Tags (2)
0 Karma
1 Solution

jkat54
SplunkTrust
SplunkTrust

Yes, this is possible. Start by extracting the file name:

index=yourindex "stuck in queue" | rex "FileName:\s(?<file>.+)" 

Then create a list of file names and date/time/host

index=yourindex "stuck in queue" | rex "FileName:\s(?<file>.+)"  | table _time host file

now save this as an alert, for the trigger action add "send email", select your options on how to attach the data... schedule the alert to run however often you like.

To avoid issues with bad timestamps, use _index_earliest in your alert (optional):

index=yourindex _index_earliest=-15m  "stuck in queue" | rex "FileName:\s(?<file>.+)" | table _time host file

The search above when scheduled to run every 15 minutes, would find any events indexed in the last 15 minutes even if timestamp recognition is off and regardless of indexing latency.

I edited to remove _index_latest=@m. When you snap to on the latest and you search doesnt execute at the minute you could miss the events that come between when your search actually executes and the last time. best just to leave that off the search.

View solution in original post

0 Karma

jkat54
SplunkTrust
SplunkTrust

Yes, this is possible. Start by extracting the file name:

index=yourindex "stuck in queue" | rex "FileName:\s(?<file>.+)" 

Then create a list of file names and date/time/host

index=yourindex "stuck in queue" | rex "FileName:\s(?<file>.+)"  | table _time host file

now save this as an alert, for the trigger action add "send email", select your options on how to attach the data... schedule the alert to run however often you like.

To avoid issues with bad timestamps, use _index_earliest in your alert (optional):

index=yourindex _index_earliest=-15m  "stuck in queue" | rex "FileName:\s(?<file>.+)" | table _time host file

The search above when scheduled to run every 15 minutes, would find any events indexed in the last 15 minutes even if timestamp recognition is off and regardless of indexing latency.

I edited to remove _index_latest=@m. When you snap to on the latest and you search doesnt execute at the minute you could miss the events that come between when your search actually executes and the last time. best just to leave that off the search.

0 Karma
Got questions? Get answers!

Join the Splunk Community Slack to learn, troubleshoot, and make connections with fellow Splunk practitioners in real time!

Meet up IRL or virtually!

Join Splunk User Groups to connect and learn in-person by region or remotely by topic or industry.

Get Updates on the Splunk Community!

Persistent Queue at TcpOut — One of Splunk's Most Practical Features

Splunk introduced persistent queueing at the tcpout layer as one of the most practical resilience features in ...

Skip the Awkward Silence: Have a .conf-ersation at .conf26

Picture this. You arrive at .conf26 already having your socializing and networking plans mapped out. No ...

Rethinking Zero Trust: From Product Purchases to Logical Control Evidence

Note: This post outlines a proposed architecture and serves as an interest check. If we secure commitments ...