Splunk Search

How to do show only count result that is not equal base on two fields

hitman88
Loves-to-Learn Lots
Here is my query for checking BGP routing that goes UP and DOWN. (I only want to see when the amount of UP and DOWN are not equal for the same Neighbor on a router)
In my case i want to show only line #5 and #6.
How do i do that ? 
 
My query:
...... | rex field=_raw "(?<BGP_NEIGHBOR>neighbor\s\b\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3})"  |  rex field=_raw "(?<BGP_STATUS>(Up|Down))"  |  stats count by HOST, BGP_NEIGHBOR, BGP_STATUS
 
 
#     HOST               BGP_NEIGHBOR       BGP_STATUS       count
 
1     Router A          neighbor 10.1.1.1          Down                    1
2     Router A          neighbor 10.1.1.1          Up                          1
 
3     Router B          neighbor 10.2.2.2          Down                   1
4     Router B          neighbor 10.2.2.2          Up                         1
 
5     Router C          neighbor 10.3.3.3         Down                    2
6     Router C          neighbor 10.3.3.3         Up                          1
 
7     Router D          neighbor 10.4.4.4         Down                   2
8     Router D          neighbor 10.4.4.4         Up                         2
 
 
Labels (1)
0 Karma

yuanliu
SplunkTrust
SplunkTrust

Something like this?

 

| eventstats range(count) as varies by HOST
| where varies > 0

 

Here is an emulation you can play with and compare with real data. (I know that # is not a real field.  It doesn't affect calculation here.)

 

| makeresults format=csv data="#,HOST,BGP_NEIGHBOR,BGP_STATUS,count
1,Router A,neighbor 10.1.1.1,Down,1
2,Router A,neighbor 10.1.1.1,Up,1
3,Router B,neighbor 10.2.2.2,Down,1
4,Router B,neighbor 10.2.2.2,Up,1
5,Router C,neighbor 10.3.3.3,Down,2
6,Router C,neighbor 10.3.3.3,Up,1
7,Router D,neighbor 10.4.4.4,Down,2
8,Router D,neighbor 10.4.4.4,Up,2"
``` the above emulates
.....
| rex field=_raw "(?<BGP_NEIGHBOR>neighbor\s\b\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3})"
| rex field=_raw "(?<BGP_STATUS>(Up|Down))"
| stats count by HOST, BGP_NEIGHBOR, BGP_STATUS
```

 

Combining this with the above search gives

#BGP_NEIGHBORBGP_STATUSHOSTcountvaries
5neighbor 10.3.3.3DownRouter C21
6neighbor 10.3.3.3UpRouter C11
Tags (1)
0 Karma

hitman88
Loves-to-Learn Lots

Thank you  yuanliu 
It is working   😊

0 Karma
Get Updates on the Splunk Community!

[Puzzles] Solve, Learn, Repeat: Dynamic formatting from XML events

This challenge was first posted on Slack #puzzles channelFor a previous puzzle, I needed a set of fixed-length ...

Enter the Agentic Era with Splunk AI Assistant for SPL 1.4

  &#x1f680; Your data just got a serious AI upgrade — are you ready? Say hello to the Agentic Era with the ...

Stronger Security with Federated Search for S3, GCP SQL & Australian Threat ...

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