Splunk Search

Internal lookup

mrdaniel
Explorer

I need to do a lookup on search result with data from splunk internal. I have a log which logs when a user login and what PID that user get assigned to such as:

PID: 2938 [DATE]

22: Command [username]

In the same log the actions the user takes during the session is logged with the following format:

PID: 2938 [DATE]
22: Command [custom data]

Now i would like to generate an report using this data and translate the PID to a username using lookup. The result would be a table with Username, PID and Command.

When i search for lookup information i can find that i can do lookups from scripts or CSV files, not from Splunk queries, is it possible to do such query?

Tags (1)
0 Karma
1 Solution

ziegfried
Influencer

You could either use the join or transaction command to combine the metadata of 2 searches.

Or use stats to aggregate the information on a unqiue key:

<search maching both events> | stats first(Command) as Command first(Username) as Username by PID

Another, more complicated option is to write a scripted lookup or a command which can execute searches in Splunk. But I don't think this is necessary.

View solution in original post

0 Karma

mrdaniel
Explorer

Thanks i had to modify this a bit as there are more than one Command, so I use

| stats list(Command) as Command first(Username) as Username by PID

0 Karma

ziegfried
Influencer

You could either use the join or transaction command to combine the metadata of 2 searches.

Or use stats to aggregate the information on a unqiue key:

<search maching both events> | stats first(Command) as Command first(Username) as Username by PID

Another, more complicated option is to write a scripted lookup or a command which can execute searches in Splunk. But I don't think this is necessary.

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 ...