Splunk Search

How to get the rows changed since last time I executed the query?

shahhe
Explorer

Is there a way I can do a search so that it returns the rows inserted since last time I ran the query?

earliest=last time I ran the search

Thanks.

Tags (2)
1 Solution

Paolo_Prigione
Builder

If you are speaking about a scheduled search, than the answer is definitely yes: you do that by playing with the frequency of execution and earliest/latest times. E.g. If you automatically run the query every 30 minutes, you might want to have:

... earliest=-31m@m latest=-1m@m

To pick 30 mnutes worth of data, but allowing splunk a 1 minute delay to index data which has just arrived.

If instead you are speaking about manual execution I don't think that is easily feasible.

View solution in original post

Paolo_Prigione
Builder

If you are speaking about a scheduled search, than the answer is definitely yes: you do that by playing with the frequency of execution and earliest/latest times. E.g. If you automatically run the query every 30 minutes, you might want to have:

... earliest=-31m@m latest=-1m@m

To pick 30 mnutes worth of data, but allowing splunk a 1 minute delay to index data which has just arrived.

If instead you are speaking about manual execution I don't think that is easily feasible.

Paolo_Prigione
Builder

I see...then why not use a saved and scheduled search, which fires your python script when it finds new events? The script would receive a csv of the new results and save you a headache 😉

0 Karma

shahhe
Explorer

I have a python script that I want to run when certain event occurs and I want to get data that changed since last time I ran the query.
Right now I am saving the timestamp to the file and use it next time I run the query.

0 Karma
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!

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 ...

Can’t Make It to Boston? Stream .conf25 and Learn with Haya Husain

Boston may be buzzing this September with Splunk University and .conf25, but you don’t have to pack a bag to ...