Splunk Search

How to combine two field results into single field permanently ?

navd
New Member

Lets say I have extracted two fields rs_time1 and rs_time2. But now, I want to merge the values from these fields to one single field called rs_time . I have the following query, which does correctly what I wanted in search time , but is there a way to do it permanently rather than during search time ?

| eval "rs_time"=coalesce(rs_time1,rs_time2)
|stats avg(rs_time) as res_time
0 Karma

marycordova
SplunkTrust
SplunkTrust
  1. please post a sample of the data
  2. are the fields rs_time1 and rs_time2 always present in all events, mutually exclusive, or sometimes both, sometimes one of them, and sometimes neither?
  3. are you performing the extraction or are they naturally identified fields by Splunk?

assuming Splunk is identifying the fields and that you have not manually extracted them:

in props.conf

[sourcetype]
EVAL-rs_time = if(isnotnull('rs_time1'),'rs_time1','rs_time2')
@marycordova
0 Karma

nick405060
Motivator

If the data comes from a heavy forwarder, you can use transforms.conf to create the merged field before the data is ingested to your indexers

0 Karma

horsefez
Motivator

Hey @navd,

sure it's possible and you already have the right strategy with the coalesce command.

I posted you a link about Calculated Fields that will help you further.

http://docs.splunk.com/Documentation/Splunk/7.1.2/Knowledge/definecalcfields

Tell us if you need further assistance.

0 Karma

horsefez
Motivator

@navd,

did this help you?

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!

What Is Splunk? Here’s What You Can Do with Splunk

Hey Splunk Community, we know you know Splunk. You likely leverage its unparalleled ability to ingest, index, ...

Level Up Your .conf25: Splunk Arcade Comes to Boston

With .conf25 right around the corner in Boston, there’s a lot to look forward to — inspiring keynotes, ...

Manual Instrumentation with Splunk Observability Cloud: How to Instrument Frontend ...

Although it might seem daunting, as we’ve seen in this series, manual instrumentation can be straightforward ...