Splunk Search

How to combine two fields into one field?

splunknewby
Path Finder

How do I combine two fields into one field? I've tried the following (http://answers.splunk.com/answers/8334/help-with-combining-fields.html) options, but the:

eval IP = src_ip." / ".dst_ip

However, this does not result in a new IP field in my searches.

0 Karma
1 Solution

MuS
Legend

Hi splunknewby,

this works perfect with this example:

| gentimes start=-1 | eval src_ip="1.1.1.1" | eval dst_ip="2.2.2.2" | eval IP = src_ip." / ".dst_ip

Do you get src_ip or dst_ip fields in your events? Because this will only work if you get those fields in the search result.

cheers, MuS

View solution in original post

aljohnson_splun
Splunk Employee
Splunk Employee

are you maybe looking to make the values for each field accessible under one field's name ?

... | eval combined_ip = coalesce(src_ip, dst_ip)

woodcock
Esteemed Legend

Some fields may not always have a value so try this:

...  | fillnull src_ip dst_ip | eval IP = src_ip . " /  ". dst_ip

MuS
Legend

Hi splunknewby,

this works perfect with this example:

| gentimes start=-1 | eval src_ip="1.1.1.1" | eval dst_ip="2.2.2.2" | eval IP = src_ip." / ".dst_ip

Do you get src_ip or dst_ip fields in your events? Because this will only work if you get those fields in the search result.

cheers, MuS

splunknewby
Path Finder

Thanks MuS.

0 Karma

MuS
Legend

You're welcome 🙂

0 Karma
Career Survey
First 500 qualified respondents will receive a $20 gift card! Tell us about your professional Splunk journey.

Can’t make it to .conf25? Join us online!

Get Updates on the Splunk Community!

Take Action Automatically on Splunk Alerts with Red Hat Ansible Automation Platform

 Are you ready to revolutionize your IT operations? As digital transformation accelerates, the demand for ...

Calling All Security Pros: Ready to Race Through Boston?

Hey Splunkers, .conf25 is heading to Boston and we’re kicking things off with something bold, competitive, and ...

Beyond Detection: How Splunk and Cisco Integrated Security Platforms Transform ...

Financial services organizations face an impossible equation: maintain 99.9% uptime for mission-critical ...