Splunk Search

Create a new field based on existing filelds

sidtalup27
Explorer

Hello,

My requirement is if the field "fields.summary" contains events that contain ".DT", then I want to create a new field "Summary", and set the value of the new field as Security Incident. I have created the below query, but its not working as expected. 

index="main" AND source=jira | spath
| eval summary=if(match (fields.summary,".DT-"),"Security Incident","no")

Please advise.

--
Thanks,
Siddarth

Labels (1)
0 Karma
1 Solution

ITWhisperer
SplunkTrust
SplunkTrust

The match function uses a regular expression syntax to match the value in the field - "." is a wildcard character in regular expressions so these (along with other special characters) need to be escaped.  Field names with special characters should also be quoted with single quotes. Try this

index="main" AND source=jira | spath
| eval summary=if(match ('fields.summary',"\.DT\-"),"Security Incident","no")

 

View solution in original post

ITWhisperer
SplunkTrust
SplunkTrust

The match function uses a regular expression syntax to match the value in the field - "." is a wildcard character in regular expressions so these (along with other special characters) need to be escaped.  Field names with special characters should also be quoted with single quotes. Try this

index="main" AND source=jira | spath
| eval summary=if(match ('fields.summary',"\.DT\-"),"Security Incident","no")

 

Get Updates on the Splunk Community!

Buttercup Games: Further Dashboarding Techniques (Part 6)

This series of blogs assumes you have already completed the Splunk Enterprise Search Tutorial as it uses the ...

Technical Workshop Series: Splunk Data Management and SPL2 | Register here!

Hey, Splunk Community! Ready to take your data management skills to the next level? Join us for a 3-part ...

Splunk Observability Synthetic Monitoring - Resolved Incident on Detector Alerts

We’ve discovered a bug that affected the auto-clear of Synthetic Detectors in the Splunk Synthetic Monitoring ...