Splunk Search

Regex for changing date

aniketb
Path Finder

Hi,

I want to check daily if my file generated successfully. The filename is prefixed by date so e.g.

3 march i'll have a filename like: 20160302-myfile
2 march - 20160301-myfile

I retain the files in folder for 3 months so just using *-myfile doesn't work for me.

Can splunk regex autoincrement the date everyday?

Tags (3)
0 Karma

somesoni2
SplunkTrust
SplunkTrust

Try something like this

sourcetype=xyz "/my folder/ mysubfolder" [| gentimes start=-1 | eval search=strftime(now(),"%Y%m%d') | table search ] 

The subsearch will generate a value in the format %Y%m%d (2010303 for today) and return the text value of it to main search.

0 Karma

somesoni2
SplunkTrust
SplunkTrust

So, the data is ingested already and you want to alert OR check if you received file for today (or Yesterday) using Splunk search?

0 Karma

aniketb
Path Finder

Yes my log does show it. e.g.

today's log will show

/my folder/ mysubfolder 20160302-myfile.zip 20160301-myfile.zip .....

I need the search string to search on:

sourcetype=xyz "/my folder/ mysubfolder" 20160301 (this variable should change automatically everyday)

0 Karma
Get Updates on the Splunk Community!

Enterprise Security Content Update (ESCU) | New Releases

In the last month, the Splunk Threat Research Team (STRT) has had 2 releases of new security content via the ...

Announcing the 1st Round Champion’s Tribute Winners of the Great Resilience Quest

We are happy to announce the 20 lucky questers who are selected to be the first round of Champion's Tribute ...

We’ve Got Education Validation!

Are you feeling it? All the career-boosting benefits of up-skilling with Splunk? It’s not just a feeling, it's ...