- Mark as New
- Bookmark Message
- Subscribe to Message
- Mute Message
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
I have two fields, application and servletName. I'd like to have them as column names in a chart. I'm currently trying to use eval to make a new variable named fullName, and concatenate the values for application and servletName with a dash(-) in the middle. How do I do this?
Thanks, Brett
- Mark as New
- Bookmark Message
- Subscribe to Message
- Mute Message
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Well...a typo did it.
eval fullName=applicationName. "-" .servletName
Turns out that not putting the right name of a field causes the entire operation to return nada.
- Mark as New
- Bookmark Message
- Subscribe to Message
- Mute Message
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
This is a question that has many hits. I just wanted to point out that there is another possibility
<basesearch> | strcat field1 " some text: " field2 " more text: " field3 newField
This will concatenate fields and text to the new field 'newField'
strcat has the advantage that it will still create the new field if one of the fields that are concatenated are empty/missing
http://docs.splunk.com/Documentation/Splunk/latest/SearchReference/strcat
- Mark as New
- Bookmark Message
- Subscribe to Message
- Mute Message
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
'strcat' works great for more than two fields as well. The 'allrequired=f' flag also allows you to concatenate the fields that exist and ignore those that don't.
Example:
| strcat allrequired=f email "|" uname "|" secondaryuname identity
The above will combine the three fields, 'email', 'uname', and 'secondaryuname' into the single field 'identity', delimitating by the pipe character.
- Mark as New
- Bookmark Message
- Subscribe to Message
- Mute Message
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
You can concatenate two fields using eval
ex: eval Full_Name= 'First Name'. " " .'Last Name'
- Mark as New
- Bookmark Message
- Subscribe to Message
- Mute Message
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Excellent! This is what I needed to concatenate a tag to another string. Eval is not working for this, but this is :
| strcat host "(" tag::host ")" label
- Mark as New
- Bookmark Message
- Subscribe to Message
- Mute Message
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
You can use the eval search command for this.
Concatenate fieldA, a dash, and fieldB into newField:
| eval newField= fieldA."-".fieldB
- Mark as New
- Bookmark Message
- Subscribe to Message
- Mute Message
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Amazing, this is exactly what I've been looking for, ty!
- Mark as New
- Bookmark Message
- Subscribe to Message
- Mute Message
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Well...a typo did it.
eval fullName=applicationName. "-" .servletName
Turns out that not putting the right name of a field causes the entire operation to return nada.
- Mark as New
- Bookmark Message
- Subscribe to Message
- Mute Message
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content

I accepted this as the solution because it was the earliest one that mentioned eval with periods/dots for the concatenation which is the most common approach I've seen in the last 12 years since this answer was written.
Nice work!
I do believe the | strcat works too, but didnt check before writing this.
