Splunk Search

How to use a daily updated lookup table to search for new sourcetypes added in the past 24 hours?

krishanpatel
Engager

I want to create a search that displays any newly added sourcetypes in the past 24 hrs. I've created a report that outputs a lookup table and is scheduled to run/update once a day. My report search string is below:

... | inputlookup lookup.csv append=t | stats count by sourcetype | table sourcetype | outputlookup lookup.csv

I am struggling to figure out a way to search the lookup table for newly added sourcetypes. Does anyone know how I could do that? Or is there a better method in trying to accomplish this?

Tags (3)
1 Solution

lguinn2
Legend

I hesitate to say "you are doing it wrong" but stats is really an inefficient way to get a list of sourcetypes. The metadata command is extremely fast and gives you everything you need:

Your daily scheduled search could look like this:

| metadata type=sourcetypes | outputlookup lookup.csv

You can also figure out which sourcetypes are new by looking at the firstTime field:

| metadata type=sourcetypes | where firstTime > now()-86400

Not really sure why you even need the lookup table...

View solution in original post

lguinn2
Legend

I hesitate to say "you are doing it wrong" but stats is really an inefficient way to get a list of sourcetypes. The metadata command is extremely fast and gives you everything you need:

Your daily scheduled search could look like this:

| metadata type=sourcetypes | outputlookup lookup.csv

You can also figure out which sourcetypes are new by looking at the firstTime field:

| metadata type=sourcetypes | where firstTime > now()-86400

Not really sure why you even need the lookup table...

krishanpatel
Engager

Thank you. This is what I was looking for and is a much easier approach.

0 Karma

MuS
Legend

Hi krishanpatel,

try something like this:

sourcetype=* | search NOT [ | outputlookup lookup.csv ]

hope this helps to get you started...

cheers, MuS

Career Survey
First 500 qualified respondents will receive a $20 gift card! Tell us about your professional Splunk journey.

Can’t make it to .conf25? Join us online!

Get Updates on the Splunk Community!

Community Content Calendar, September edition

Welcome to another insightful post from our Community Content Calendar! We're thrilled to continue bringing ...

Splunkbase Unveils New App Listing Management Public Preview

Splunkbase Unveils New App Listing Management Public PreviewWe're thrilled to announce the public preview of ...

Leveraging Automated Threat Analysis Across the Splunk Ecosystem

Are you leveraging automation to its fullest potential in your threat detection strategy?Our upcoming Security ...