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!

Splunk Custom Visualizations App End of Life

The Splunk Custom Visualizations apps End of Life for SimpleXML will reach end of support on Dec 21, 2024, ...

Introducing Splunk Enterprise 9.2

WATCH HERE! Watch this Tech Talk to learn about the latest features and enhancements shipped in the new Splunk ...

Adoption of RUM and APM at Splunk

    Unleash the power of Splunk Observability   Watch Now In this can't miss Tech Talk! The Splunk Growth ...