Splunk Search

How to compare 2 field values and exclude matching results from the final output / count

promukh
Path Finder

Below is my search output for the SPL i am running.

`
db_1

oracle_test

db2_bio

oracle_890

n88888

n7777

server_2

n87896
bg8768
j987653
n88888

n7777

How do i exclude the field records which are identical between 2 fields like in this case -- (n88888 & n7777)

I tried using there where clause /Search , but without any success ..

SPL used to display fields records which are not identical ---

|splunk command | where db_1 != server_2 ( Not wokring )

|splunk Command | fields db_1,server_2 | search db_1 !=server_2 ( Not working )

Any clue/help will be appreciated ?

0 Karma

to4kawa
Ultra Champion

what's field name, n88888 & n7777?
and

oracle_test db2_bio oracle_890 n88888 n7777
n87896 bg8768 j987653 n88888 n7777

your result is this?

0 Karma

promukh
Path Finder

field names are -- source1.db_1 & source1.server_2

0 Karma

promukh
Path Finder

yes ..correct .. i want to exclude the matching records from both fields

0 Karma

to4kawa
Ultra Champion

db_1:
source1.db_1 n88888
source1.server_2 n7777

server_2:
source1.db_1 n88888
source1.server_2 n7777
this 2 results is exclude. right?

0 Karma

promukh
Path Finder

yes want to exclude those 2 values in the final output

0 Karma

promukh
Path Finder

ok , I was able to resolve using a single quote around the field name along with a where clause.

|splunk command | where 'db_1'!='server_2'

Found the below input in the splunk documentation which helped ..

https://docs.splunk.com/Documentation/SplunkInvestigate/Current/SearchReference/WhereCommandOverview

where 'host-name'="buttercup" If the expression references a field name that contains characters other than a-z, A-Z, 0-9, or the underscore ( _ ) character, the field name must be surrounded by single quotation marks.

Thank You

0 Karma

to4kawa
Ultra Champion

what's your query?
server and db is another
host?

0 Karma
Get Updates on the Splunk Community!

Built-in Service Level Objectives Management to Bridge the Gap Between Service & ...

Wednesday, May 29, 2024  |  11AM PST / 2PM ESTRegister now and join us to learn more about how you can ...

Get Your Exclusive Splunk Certified Cybersecurity Defense Engineer at Splunk .conf24 ...

We’re excited to announce a new Splunk certification exam being released at .conf24! If you’re headed to Vegas ...

Share Your Ideas & Meet the Lantern team at .Conf! Plus All of This Month’s New ...

Splunk Lantern is Splunk’s customer success center that provides advice from Splunk experts on valuable data ...