Splunk Search

How to calculate field to replace value of field?

jason_hotchkiss
Communicator

Hello - 

I have a table with the following:

host

HOST FQDN DNS_NAME HOST_MATCH INDEX
hostalpha hosta.mydomain.com hosta false index_a
hosta host - true index_b


Created from the following search:

base_search
| rex field=FQDN ""^(?<DNS_NAME>[^.]+)\..*$"
| fillnull value="-" DNS_NAME
|eval HOST_MATCH="if(host='DNS_NAME',"true","false")

How would I replace the do the following:

1.  If HOST != DNS_NAME, Make HOST = DNS_NAME
2.  If DNS_NAME = "-" MAKE DNS_NAME = HOST

Thanks!

Labels (2)
0 Karma
1 Solution

ITWhisperer
SplunkTrust
SplunkTrust

Just do the evaluations in the opposite order

| eval DNS_NAME=if(DNS_NAME == "-", HOST, DNS_NAME)
| eval HOST=if(HOST != DNS_NAME, DNS_NAME, HOST)

View solution in original post

ITWhisperer
SplunkTrust
SplunkTrust

Just do the evaluations in the opposite order

| eval DNS_NAME=if(DNS_NAME == "-", HOST, DNS_NAME)
| eval HOST=if(HOST != DNS_NAME, DNS_NAME, HOST)

jason_hotchkiss
Communicator

@ITWhisperer thank you.  I was way overthinking this.  Much appreicated!

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!

Community Content Calendar, September edition

Welcome to another insightful post from our Community Content Calendar! We're thrilled to continue bringing ...

Splunkbase Unveils New App Listing Management Public Preview

Splunkbase Unveils New App Listing Management Public PreviewWe're thrilled to announce the public preview of ...

Leveraging Automated Threat Analysis Across the Splunk Ecosystem

Are you leveraging automation to its fullest potential in your threat detection strategy?Our upcoming Security ...