-2
index=name conn "connection from"  
    [search index=name 
        [| inputlookup UIDlist.csv 
        |rename UID AS uid
        | fields uid ]
    "BIND"  
   | fields conn ]  
| rex field=_raw "connection from (?<FROM_IP>\d+\.\d+\.\d+\.\d+):"  
| stats count by FROM_IP

tst.csv file has list of UID so that it can give o/p for one user then other and so on ...
I want the table FROM_IP with which uid

O/p of two query used above :

index=name BIND uid | fields conn

[10/Nov/2020:06:38:40 +0000] conn=111111 op=4238 msgId=4239 - BIND dn="uid=uid,ou=xxx,o=xxxx,o=email" method=128 version=3

index=name conn "connection from" | rex field=_raw "connection from (?<FROM_IP>\d+.\d+.\d+.\d+):" | stats count by FROM_IP

[09/Nov/2020:22:52:55 -0800] conn=1111111 op=-1 msgId=-1 - fd=115 slot=115 xxxx connection from xx.xx.xx.xx.xx to xx.xx.xx.xx.xx

1 Answers1

0

Try this query. It's not as efficient as your original query since it reads more rows, but sometimes it can't be helped. We start by reading both connection and BIND events then putting them together using stats. Then we filter out those not in the lookup file.

index=name conn ("connection from" OR "BIND")
| stats values(*) as * by conn
| search [| inputlookup UIDlist.csv 
        |rename UID AS uid
        | return $uid ]
| rex field=_raw "connection from (?<FROM_IP>\d+\.\d+\.\d+\.\d+):"
| rex field=dn "uid=(?<uid>[^,]+)"
| stats count by FROM_IP, uid
RichG
  • 4,202
  • 1
  • 12
  • 23