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!

Enterprise Security Content Update (ESCU) | New Releases

In November, the Splunk Threat Research Team had one release of new security content via the Enterprise ...

Index This | Divide 100 by half. What do you get?

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

Stay Connected: Your Guide to December Tech Talks, Office Hours, and Webinars!

❄️ Celebrate the season with our December lineup of Community Office Hours, Tech Talks, and Webinars! ...