Splunk Enterprise

How to receive delta from two different sources?

hillsmtb7
Explorer

We are trying to output computers that appear in index A but not appear in Index B.  We want to ensure computers are being deployed with the correct software on them.

Index A
----------------------------------------------------
| name | objectclass | field 1 | field 2 | field 3 |
----------------------------------------------------
| PC 1   | computer     | x           | x           | x           |
| PC 2   | computer     | x           | x           | x           |
| PC 3   | computer     | x           | x           | x           |
| PC 4   | computer     | x           | x           | x           |
| PC 5   | computer     | x           | x           | x           |
| PC 6   | computer     | x           | x           | x           |


Index B
----------------------------------------------------
| cname | objectclass | field 1 | field 2 | field 3 |
----------------------------------------------------
| PC 1     | computer     | x            | x           | x           |
| PC 2     | computer     | x            | x           | x           |
| PC 5     | computer     | x            | x           | x           |
| PC 6     | computer     | x            | x           | x           |

 

I need the output to only show PC 3 and 4 so this can be supplied to the proper team to install the application.  I have tried join with type left and outer.  Also I have attempted stats.  However, I believe my logic is wrong.

Your help is greatly appreciated.

Labels (1)
0 Karma

hillsmtb7
Explorer

That did not work.   It returns 0 results and when we run the indexes independently index A shows PC3 and index B does not contain PC3.  Could it be an issue with the filed names being different for the computer names?

0 Karma

ITWhisperer
SplunkTrust
SplunkTrust

Yes. Just rename one of the fields to the same name or use coalese() to eval the fields together i.e. when name is null, set it to cname.

0 Karma

hillsmtb7
Explorer

Negative GhostRider...did not work.

0 Karma

ITWhisperer
SplunkTrust
SplunkTrust

What have you tried?

0 Karma

hillsmtb7
Explorer

I have tried the first suggestion you provided.  Then on the rename of the filed I tried the following:

(index="A" ) OR (index="B" sourcetype="B.1")

| rename cname as name

| stats value(*) as * values(index) as index by name

| where mvcount(index)=1 AND index="A"

 

Just for clarity, I have ran the index independently and receive the following for PC3:

index="A" name=PC3 (Results: PC3 appears in the list for the past 30 days)

index="B" sourcetype="B.1" cname=PC3 (Results: PC3 does not appear for the past 30 days.)

Need only the machines that show up in index A and not in index B to display.

0 Karma

ITWhisperer
SplunkTrust
SplunkTrust

What do you get for this?

(index="A" ) OR (index="B" sourcetype="B.1")
| rename cname as name
| stats value(*) as * values(index) as index by name
| where name="PC3"
0 Karma

hillsmtb7
Explorer

hillsmtb7_0-1653412798645.png

This is what I get.   

0 Karma

ITWhisperer
SplunkTrust
SplunkTrust

That would seem to suggest that PC3 doesn't exist in either index as that name - have the names been shortened or extended in either index or been modified e.g. uppercase, etc. - the names will have to match precisely (unless we do something different)?

0 Karma

hillsmtb7
Explorer

Well that's exactly not true as PC3 does exist on the first index just not in the second one when searched individually.

Index A

hillsmtb7_0-1653418577714.png

Index B

hillsmtb7_1-1653418595955.png

 

0 Karma

ITWhisperer
SplunkTrust
SplunkTrust

The initial search is case insensitive. What do you find when you try it like this?

index="A"
| where name="PC3"
index="B"
| where name="PC3"
0 Karma

hillsmtb7
Explorer

I wont try index B cause there is no data there for that PC, but in index A I attempted the following:

index=A

| where name="PC3" (Results: Computer appears)

But when I search as follows:

index=A

| where name="pc3" (Results: Computer does not appear)

It is case sensitive at the where.  I thought it was case insensitive throughout.  Where do I change the case?

0 Karma

ITWhisperer
SplunkTrust
SplunkTrust

Try this

(index="A" OR index="B")
| eval name=upper(coalesce(name,cname))
| stats value(*) as * values(index) as index by name
| where mvcount(index)=1 AND index="A"
0 Karma

hillsmtb7
Explorer

We might be getting closer.  Why are we placing the following:

values(*) as *

0 Karma

ITWhisperer
SplunkTrust
SplunkTrust

This is gathering the values from the two events into one event

indexnamefield1...
APC2xyz...
BPC2xyz...

become

indexnamefield1...
A, B (multi-value)PC2xyz...

index has a mvcount = 1 when it appears in only one index - which is what you are after, and you check that that index is "A" to find the ones that are in "A" and not "B"

0 Karma

ITWhisperer
SplunkTrust
SplunkTrust

Try something along these lines

(index="A" OR index="B")
| stats value(*) as * values(index) as index by name
| where mvcount(index)=1 AND index="A"
0 Karma
Get Updates on the Splunk Community!

.conf25 Community Recap

Hello Splunkers, And just like that, .conf25 is in the books! What an incredible few days — full of learning, ...

Splunk App Developers | .conf25 Recap & What’s Next

If you stopped by the Builder Bar at .conf25 this year, thank you! The retro tech beer garden vibes were ...

Congratulations to the 2025-2026 SplunkTrust!

Hello, Splunk Community! We are beyond thrilled to announce our newest group of SplunkTrust members!  The ...