Alerting

How to display the selected text from log obtained from search in a subject of email while creating an alert ??

Sawanshar93
New Member

Sample Example
Error occurred in app Myworld123

I want to display app name e.g "Myworld123" in subject of mail.

I can't used result. since that text is not part of any field in a log.

Tags (2)
0 Karma

nawazns5038
Builder

Try to bring the value in top of the result table and use $result.fieldname$ in the subject while setting up the alert where the fieldname is the name of the field that the value is.

If your query does not produce the desired value in the results table try appendcols and join the value to the query.

0 Karma

Sawanshar93
New Member

I can't use $result.fieldname$ since the text which I want to display as subject is not part of field of log.

0 Karma

micahkemp
Champion

You can add new fields to your results as you need. | eval subject="This is a test subject" You could then use $result.subject$ in your alert.

0 Karma

nawazns5038
Builder

try extracting the value through field extraction given by Splunk or by using regex ( rex command )

0 Karma

somesoni2
Revered Legend

How are you getting that app name then?? A lookup?? Hardcoded/static value??

0 Karma

Sawanshar93
New Member

app name is name given to particular section of text of log, however there is not such field name appname in either selected field or interesting field of result obtained by triggering queries.

My query is like this,

APP1 OR APP2 OR APP3 java.io.IOException

so whenever this pattern is occurred a new alert will be raised.
alert are getting raised perfectly but we're unable to identified for which APP we're getting that particular error.

suppose alert is raised is raised due to failure of APP2 so we expect APP2 name in our subject of Alert.

as suggested by @nawazns5038, use $result.fieldname$ to extract appname and displayed it to subject but unfortunately whenever we trigger this query we don't get that selected text which we want to display as subject as selected field or interesting field.

We can create 3 separate alert for each app and email subject as hardcode app, but I think this is very redundant and unnecessary.

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!

Announcing Modern Navigation: A New Era of Splunk User Experience

We are excited to introduce the Modern Navigation feature in the Splunk Platform, available to both cloud and ...

Modernize your Splunk Apps – Introducing Python 3.13 in Splunk

We are excited to announce that the upcoming releases of Splunk Enterprise 10.2.x and Splunk Cloud Platform ...

Step into “Hunt the Insider: An Splunk ES Premier Mystery” to catch a cybercriminal ...

After a whole week of being on call, you fell asleep on your keyboard, and you hit a sequence of buttons that ...