Splunk Search

Joining two fields together

Michael_Schyma1
Contributor

How do I join two fields together so there is not whitespace in my table. I want to join sfailed and EventCodeDescription so that it will list "Shutdown or reboot"

index="Desktop" (EventCode=513 OR EventCode=3003) OR reboot EventCodeDescription= "sfailed" OR "Shutdown"| rex"Shutdown\s\S+(?\s\S+)" | table _time sfailed host user EventCodeDescription | rename _time AS Time | convert timeformat="%H/%M/%S %d.%m.%Y" ctime(Time) | rename user AS Username | rename host AS "Machine Name" EventCodeDescription AS "Description"

Tags (1)
0 Karma
1 Solution

MHibbin
Influencer

You should probably use eval to create a new field, and then use coalesce to combine these two fields. e.g.

...| eval newField=coalesce(EventCodeDescription,sfailed)|...

View solution in original post

MHibbin
Influencer

You should probably use eval to create a new field, and then use coalesce to combine these two fields. e.g.

...| eval newField=coalesce(EventCodeDescription,sfailed)|...

sowings
Splunk Employee
Splunk Employee

Coalesce is probably not what you want; it picks the first non-null from the list and returns that. Instead, string manipulation will do what you want:


eval newField=EventCodeDescription + sfailed

Get Updates on the Splunk Community!

Stay Connected: Your Guide to May Tech Talks, Office Hours, and Webinars!

Take a look below to explore our upcoming Community Office Hours, Tech Talks, and Webinars this month. This ...

They're back! Join the SplunkTrust and MVP at .conf24

With our highly anticipated annual conference, .conf, comes the fez-wearers you can trust! The SplunkTrust, as ...

Enterprise Security Content Update (ESCU) | New Releases

Last month, the Splunk Threat Research Team had two releases of new security content via the Enterprise ...