Splunk Search

Creating a new field depending on wildcard search

Path Finder

Hi I know this is probably an easy one but I'm new and need some help.

I have the following Field Called "Account Name"

Account Name                                  

Alan Test Account                             

Debbie Production Account         

John Dev Account                            

Ed Test Account                                 

I would like to create a new field called Environment that matches Test, Production ,Dev

Account Name                                  Environment

Alan Test Account                             Test

Debbie Production Account         Production

John Dev Account                            Dev

Ed Test Account                                 Test

Labels (1)
0 Karma

Ultra Champion

One possible approach:

<your search>
| rex field='Account Name' "\S+\s(?<Environment>\S+)\sAccount"
0 Karma


You can validate that you are extracting the environment field from all the results with the below query:

<your search>
| rex field='Account Name' "\S+\s(?<Environment>\S+)\sAccount"
| search NOT Environment=*
| table "Account Name"

If you see any results that mean those account names are differently formatted than what you provided examples here.

If you have "No results" in this search you are good to go. You can use the solution provided by @PickleRick .

0 Karma
Get Updates on the Splunk Community!

Splunk Forwarders and Forced Time Based Load Balancing

Splunk customers use universal forwarders to collect and send data to Splunk. A universal forwarder can send ...

NEW! Log Views in Splunk Observability Dashboards Gives Context From a Single Page

Today, Splunk Observability releases log views, a new feature for users to add their logs data from Splunk Log ...

Last Chance to Submit Your Paper For BSides Splunk - Deadline is August 12th!

Hello everyone! Don't wait to submit - The deadline is August 12th! We have truly missed the community so ...