Splunk Search

How to dynamically put today's date in the source field of an xml input value?

Bhuavana
Explorer

Hi Team,

How do I dynamically put today's date value in the source field of an xml input value?

I have the search below where I need to dynamically put today's date in the source field having xml as input value. Currently i have hardcoded 2015-02-03 but it should take today's date in the future.

index=test source="/env/transactionlog/aaa_Logs/TL_aaa_WUCARD_LOOKUP_2015-02-03.xml" | rex field=_raw "(?P[^<]+)" | stats count by Tran

Please suggest how to achieve this?

Tags (3)
0 Karma

MuS
Legend

Hi Bhunavana,

take this example:

index=_internal [| gentimes start=-1 | eval source="foo.boo-" + strftime(now(), "%Y-%m-%d") | return source]

this will translate to this Splunk litsearch:

litsearch index=_internal source="foo.boo-2015-02-03" 

So using your provided search try something like this:

index=test [| gentimes start=-1 | eval source="/env/transactionlog/aaa_Logs/TL_aaa_WUCARD_LOOKUP_" + strftime(now(), "%Y-%m-%d") + ".xml" | return source ] | rex field=_raw "(?P[^<]+)" | stats count by Tran

Hope this helps ...

cheers, MuS

Get Updates on the Splunk Community!

Introducing the 2024 SplunkTrust!

Hello, Splunk Community! We are beyond thrilled to announce our newest group of SplunkTrust members!  The ...

Introducing the 2024 Splunk MVPs!

We are excited to announce the 2024 cohort of the Splunk MVP program. Splunk MVPs are passionate members of ...

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