Splunk Search

How do you use the value of the lookup filename as a field in the search result?

roayers
Explorer

Here is the search and lookup,

I need to capture the value, last_logon_lookup_20180928.csv

We need the value in bold above as a value in a field in the results called sourcefile

Search is shown below

index=wineventlog sourcetype=WinEventLog:Security  [| inputlookup last_logon_lookup_20180928.csv 
    | fields Account_Name] | lookup last_logon_lookup_20180928.csv Account_Name output Account_Name LASTLOGON 
| table  Account_Name LASTLOGON sourcefile

One thought we had was to use the REST API, but we could not get that integrated in the search to produce the required results

This gets us the lookup filename

| rest /services/data/transforms/lookups | search  filename=*last* |table sourcefile

Thanks In Advance

Robert

0 Karma

woodcock
Esteemed Legend

Try this:

index=wineventlog sourcetype=WinEventLog:Security
[| inputlookup last_logon_lookup_20180928.csv 
 | fields Account_Name] 
| lookup [ |rest/services/data/transforms/lookups | search filename=*last* | head 1 | return $filename ] Account_Name OUTPUT Account_Name LASTLOGON 
| table  Account_Name LASTLOGON sourcefile
0 Karma

nagarjuna280
Communicator

index=wineventlog sourcetype=WinEventLog:Security [| inputlookup last_logon_lookup_20180928.csv
| fields Account_Name] | lookup last_logon_lookup_20180928.csv Account_Name output Account_Name LASTLOGON

|eval sourcefile="last_logon_lookup_20180928.csv"
| table Account_Name LASTLOGON sourcefile

0 Karma

whrg
Motivator

Hi Robert! I'm not sure which part of the main search is dynamic: Is it both the "last_logon_lookup_20180928.csv" occurrences or is it "sourcefile" at the very end?

How about using a dashboard with a token?

0 Karma
Get Updates on the Splunk Community!

Index This | I am a number, but when you add ‘G’ to me, I go away. What number am I?

March 2024 Edition Hayyy Splunk Education Enthusiasts and the Eternally Curious!  We’re back with another ...

What’s New in Splunk App for PCI Compliance 5.3.1?

The Splunk App for PCI Compliance allows customers to extend the power of their existing Splunk solution with ...

Extending Observability Content to Splunk Cloud

Register to join us !   In this Extending Observability Content to Splunk Cloud Tech Talk, you'll see how to ...