Splunk Search

Concatenate fields into a single string

efelder0
Communicator

I have four fields: Signature_Name, Vendor_Signature, Incident_Detail_URL, Analyst_Assessment that I need to concatenate into one field (single string) called 'Event Detail'. Additionally, I need to append a semi-colon at the end of each field. How can this be done?

Tags (1)

cmerriman
Super Champion

for the issue with MV fields and concatenation, you can always use mvjoin first to get all of the Signature Names comma separated (or any other delim)

sourcetype="incident"| sort +Severity | lookup geoip clientip as SourceIP_Address| lookup subnetlookup ip as SourceIP_Address OUTPUT subnet_name AS location | eval
client_country=replace(client_country," ","") | strcat client_city ", " client_region " " client_country mylocation | eval final_location=if(mylocation==", ",location,mylocation) | rex field=final_location "(?.) (?.)"
| eval Signature_Name=mvjoin(Signature_Name,", ")
| eval Event_Detail=Signature_Name+ ";" +Vendor_Signature+ ";" +Incident_Detail_URL+ ";" +Analyst_Assessment | table CreateTimeStamp_GMT Data_Source Reference_Number SourceIP_Address SIP_Region SIP_Country Severity Incident_Category Incident_Classification Event_Detail | outputcsv SymantecReport.csv

0 Karma

leonphelps_s
Path Finder

My issue ended up being a command ordering issue. Inadvertently had the eval command before the mv

0 Karma

efelder0
Communicator

OK, thanks. That was helpful. However, when I have multiple values in the Signature_Name field, I get no values when I try to concatenate into the Event_Detail field.

Here is my search string:

sourcetype="incident"| sort +Severity | lookup geoip clientip as SourceIP_Address| lookup subnetlookup ip as SourceIP_Address OUTPUT subnet_name AS location | eval
client_country=replace(client_country," ","") | strcat client_city ", " client_region " " client_country mylocation | eval final_location=if(mylocation==", ",location,mylocation) | rex field=final_location "(?.) (?.)" | eval Event_Detail=Signature_Name+ ";" +Vendor_Signature+ ";" +Incident_Detail_URL+ ";" +Analyst_Assessment | table CreateTimeStamp_GMT Data_Source Reference_Number SourceIP_Address SIP_Region SIP_Country Severity Incident_Category Incident_Classification Event_Detail | outputcsv SymantecReport.csv

0 Karma

leonphelps_s
Path Finder

Did you ever figure this out? "No values" when there are multiple values in the field.

0 Karma

Ayn
Legend

Use eval:

... | eval Event_Detail= Signature_Name.";".Vendor_Signature.";".Incident_Detail_URL.";".Analyst_Assessment

bbingham
Builder
| eval Event_Detail=Signature_Name+";"+Vendor_Signature+";"+Incident_Detail_URL+";"+Analyst_Assessment+";"
Career Survey
First 500 qualified respondents will receive a $20 gift card! Tell us about your professional Splunk journey.
Get Updates on the Splunk Community!

Introduction to Splunk AI

How are you using AI in Splunk? Whether you see AI as a threat or opportunity, AI is here to stay. Lucky for ...

Splunk + ThousandEyes: Correlate frontend, app, and network data to troubleshoot ...

Are you tired of troubleshooting delays caused by siloed frontend, application, and network data? We've got a ...

Maximizing the Value of Splunk ES 8.x

Splunk Enterprise Security (ES) continues to be a leader in the Gartner Magic Quadrant, reflecting its pivotal ...