Splunk Search

Output multiple fields from query to csv via output lookup

iomega311
Explorer

I have created a query that will extract specific information from my Active Directory logs, and output it into a nicely labeled table.
I would like to know if it is possible to push these fields into an outputlookup command that will create a lookup file that is usable elsewhere.

I have a query that looks similar to this:

index="Microsoft_Active_Directory" sourcetype="Active_Directory"`
| dedup AccountName
| rex field=manager "CN\x3d(?:[AP]\x2d)?(?P<manLast>[^\x5c]+)\x5c\x2c\s(?P<manFirst>[^\x2c]+)\x2cOU"
| rex field=name "(?P<nameLast>^[^\x2c]+)(?:\x2c\s(?P<nameFirst>.*))?"
| rex field=whenCreated ".*?(?P<Created>\d+\x2f\d+\x2f\d+)"
| eval Manager = toString(manFirst) + " " + toString(manLast)
| eval "Employee Name" = toString(nameFirst) + " " + toString(nameLast)
| rex field=Manager mode=sed "s/Null\sNull/N\/A/g"
| rex field=employeeID mode=sed "s/x+/N\/A/g"
| rex field="Employee Name" mode=sed "s/Null\s//g"
| rename AccountName AS Username, description AS "Job Title", physicalDeliveryOfficeName AS Location, l as City, st AS State, userPrincipalName AS "Employee E-mail", employeeID AS "Employee ID", telephoneNumber AS "Phone Number"
| table Username "Employee Name" "Job Title" Location City State "Employee E-mail" "Employee ID" "Phone Number" Manager Created

I am hoping that this query can be used to create a lookup file with these 11 fields populated that can then be used to query against in other use cases. I have tried finding my answer online before coming here and asking a question, but I cannot seem to find the correct way to do this.

And then assuming that the above is all possible, it would also be awesome to know how to make this happen dynamically so that the lookup file will be updated periodically (a dynamic lookup), say weekly, with the current AD information.

Any help given is certainly appreciated, thanks.

0 Karma
1 Solution

johnnyfrx
Path Finder
0 Karma

johnnyfrx
Path Finder

If you follow these 2 articles in order, you should be good to go:
Upload your lookup table:
http://docs.splunk.com/Documentation/Splunk/7.1.2/Knowledge/Usefieldlookupstoaddinformationtoyoureve...

Output results to a CSV lookup:
https://docs.splunk.com/Documentation/Splunk/7.1.2/Alert/OutputToCSVLookup

0 Karma
Get Updates on the Splunk Community!

Built-in Service Level Objectives Management to Bridge the Gap Between Service & ...

Wednesday, May 29, 2024  |  11AM PST / 2PM ESTRegister now and join us to learn more about how you can ...

Get Your Exclusive Splunk Certified Cybersecurity Defense Engineer at Splunk .conf24 ...

We’re excited to announce a new Splunk certification exam being released at .conf24! If you’re headed to Vegas ...

Share Your Ideas & Meet the Lantern team at .Conf! Plus All of This Month’s New ...

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