Splunk Search

How to merge two fields into one field?

lpolo
Motivator

I have the following result set coming from a search:

field_1 field_2
 1       2
 3       4
 5       6

I need to merge these two fields into a new field "output":

output
 1
 2
 3
 4
 5
 6

Thanks,
Lp

Labels (1)
Tags (2)

ibekacyril
Explorer

Sorry for the late show, but this returns null in the second field

0 Karma

seanclark
Engager

I am getting the null response as well.

0 Karma

somesoni2
Revered Legend

Is one of your fields that you're merging contains null values?

0 Karma

seanclark
Engager

Apparently they did, but I could not find where they were. I also had to manipulate this solution some to get what I wanted. I had to fields that had IPs in them so I did this.

myprecious | fillnull value="" source_address ip_address| eval output =ip_address.source_address

0 Karma

lguinn2
Legend

Here is one way- but there is probably something better

yoursearchhere |
rename field1 as output |
append [search yoursearchhere earliest=-24h |
rename field2 as output ]

This runs the search twice...

Notice that I included earliest=-24h for the inner search. Otherwise, this will search over all time - it is not affected by the time selector. [No longer true - the inner search runs over the range specified by the timerange selector.]

landen99
Motivator

The subsearch naturally carries the time of the outer search unless otherwise specified, as I understand it.

lguinn2
Legend

Agreed @landen99, but that was not true in 2012 🙂

0 Karma

Ayn
Legend

Well give more details. You didn't state that this was going to be used across millions events. Also you need to give more details on the search you're using to generate these fields. Do field1 and field2 belong to the same search result? Do both fields always occur in all events you want to apply this to?

lpolo
Motivator

This approach is expensive and might not work when dealing with millions of events.
Thanks.

0 Karma
Get Updates on the Splunk Community!

Announcing Scheduled Export GA for Dashboard Studio

We're excited to announce the general availability of Scheduled Export for Dashboard Studio. Starting in ...

Extending Observability Content to Splunk Cloud

Watch Now!   In this Extending Observability Content to Splunk Cloud Tech Talk, you'll see how to leverage ...

More Control Over Your Monitoring Costs with Archived Metrics GA in US-AWS!

What if there was a way you could keep all the metrics data you need while saving on storage costs?This is now ...