Splunk Search

insert the earliest and latest in the DBquery

radomo
Explorer

Hello

I'm breaking my brain for make one thing. I recovery the data from External database, in this point no problem, the problem success when I need insert the earliest and latest in the query.

is it possible make this? or in the other hand am I trying something impossible?

I'd tried to resolve with insert the variable into the splunkQuery but nothing.

This is the query

<input type="time">
        <default>Last 7 days</default> 
      </input>
      <searchString>| dbquery mydb limit=1000 "select DATE_FORMAT(en.fechaExpedicion,'%d-%m-%Y') as fecha, sum(something) as adds WHERE DATE(en.date) BETWEEN DATE($earliestTime$)  AND DATE($latestTime$) " | table fecha, * | addtotals fieldname="TOTAL DIA" *
</searchString>
Tags (1)
0 Karma
1 Solution

alacercogitatus
SplunkTrust
SplunkTrust

There isn't a previous search to pull earliest/latest times. You could put in fields that take earliest and latest.

<input type="text" token="earliestDBTime" /><input type="text"token="latestDBTime" />
<searchString> |dbquery mydb limit=10000 "select DATE_FORMAT(......) | table fecha * |addtotals fieldname="TOTAL DIA" * </searchString>

View solution in original post

0 Karma

alacercogitatus
SplunkTrust
SplunkTrust

There isn't a previous search to pull earliest/latest times. You could put in fields that take earliest and latest.

<input type="text" token="earliestDBTime" /><input type="text"token="latestDBTime" />
<searchString> |dbquery mydb limit=10000 "select DATE_FORMAT(......) | table fecha * |addtotals fieldname="TOTAL DIA" * </searchString>

0 Karma

radomo
Explorer

Thanks for your fast answer, you have gave me a different point of view and I like it.
It's a great solution.

Thanks

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!

What Is Splunk? Here’s What You Can Do with Splunk

Hey Splunk Community, we know you know Splunk. You likely leverage its unparalleled ability to ingest, index, ...

Level Up Your .conf25: Splunk Arcade Comes to Boston

With .conf25 right around the corner in Boston, there’s a lot to look forward to — inspiring keynotes, ...

Manual Instrumentation with Splunk Observability Cloud: How to Instrument Frontend ...

Although it might seem daunting, as we’ve seen in this series, manual instrumentation can be straightforward ...