Splunk Search

Extract value from first index and search in second index

ank15july96
Engager

Hi, I'm new to splunk so pardon if its a straightforward query

I want to extract userIds from my first index and check how many does not exist in second index

Example: index=auth-app would have field like  UID: H0XF7PQU1

So, I want to extract H0XF7PQU1 from first query and check if it exist in second query (index=main-app) and get count of ids that exist one first index but not in second. 

Conceptually, I want to get count of users that passed authentication (first index) but still did not make it to main application (second index)

Labels (5)
0 Karma
1 Solution

inventsekar
Ultra Champion

I am not sure, but, lets try this once...

index=main-app OR (index=auth-app "createsession") | rex field=_raw "UID: (?<uid>......)" | stats count(uid)

View solution in original post

0 Karma

inventsekar
Ultra Champion

Hi.. do you know if UID is extracted?

pls try

(index=auth-app OR index=main-app) UID

or, simply please try..

(index=auth-app OR index=main-app) H0XF7PQU1

update us your results, thanks.

0 Karma

ank15july96
Engager

Its a bit trickier than that
Here's my first query

index=auth-app "createSession" | rex field=_raw "UID: (?<uid>.*)"

And second query should be something like index=main-app uid | stats count

How do i put above two into what you suggested -- (index=auth-app OR index=main-app) UID | stats count

0 Karma

ank15july96
Engager

Okay, I tried this and this sorta works but one issue
Query:

index=main-app [search index=auth-app "createsession" | rex field=_raw "UID: (?<uid>......)" | table uid ] | stats count

The subquery results in something like this UID="XYZ" OR UID="ABC" etc so overall query becomes likes this

index=main-app UID="XYZ" OR UID="ABC"

But I just want to search as keyword in second index not as a UID field. So basically like this

index=main-app "XYZ" OR "ABC" 

How can I achieve this?

0 Karma

inventsekar
Ultra Champion

I am not sure, but, lets try this once...

index=main-app OR (index=auth-app "createsession") | rex field=_raw "UID: (?<uid>......)" | stats count(uid)

0 Karma

inventsekar
Ultra Champion

Please try...

index=main-app | join uid [search index=auth-app "createsession" | rex field=_raw "UID: (?<uid>......)" | fields uid ] | stats count

0 Karma
Get Updates on the Splunk Community!

Routing logs with Splunk OTel Collector for Kubernetes

The Splunk Distribution of the OpenTelemetry (OTel) Collector is a product that provides a way to ingest ...

Welcome to the Splunk Community!

(view in My Videos) We're so glad you're here! The Splunk Community is place to connect, learn, give back, and ...

Tech Talk | Elevating Digital Service Excellence: The Synergy of Splunk RUM & APM

Elevating Digital Service Excellence: The Synergy of Real User Monitoring and Application Performance ...