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!

Introducing the Splunk Community Dashboard Challenge!

Welcome to Splunk Community Dashboard Challenge! This is your chance to showcase your skills in creating ...

Built-in Service Level Objectives Management to Bridge the Gap Between Service & ...

Wednesday, May 29, 2024  |  11AM PST / 2PM ESTRegister now and join us to learn more about how you can ...

Get Your Exclusive Splunk Certified Cybersecurity Defense Engineer Certification at ...

We’re excited to announce a new Splunk certification exam being released at .conf24! If you’re headed to Vegas ...