- Mark as New
- Bookmark Message
- Subscribe to Message
- Mute Message
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
How can I reset the "search timeframe" based on data in results?
Is there any way to "reset" the "search timeframe" so that all the "commands that bin" will honor a new "search timeframe" instead of the timeframe used in the original query?
Background:
I have some data where _time doesn't mean anything useful, and I reset _time in the query itself. timechart/bin/sparkline seem to doggedly pay attention to the timeframe from the original query. Is there any way in the query to "reset" what "earliest" and "latest" are, using eventstats or similar, so that downstream commands use the calculated timeframe?
- Mark as New
- Bookmark Message
- Subscribe to Message
- Mute Message
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Can you identify the "interesting" earliest/latest time and pass them as variable using the | map command?
Or if you only need a custom length sparkline with a special start/end condition (e.g. value larger than 100), you can edit the sparkline field using mv.... commands. E.g. Leaving only 10 tailing zeros at the end of the sparkline (fieldname=spcount and sorry about the regexp):
| nomv spcount | eval spcount =replace(spcount,"(##__SPARKLINE__##,[0-9,]+[1-9]{1},)\S+(0,0,0,0,0,0,0,0,0,0)$|(##__SPARKLINE__##,[0-9,]+)","\1\2\3") | makemv delim="," setsv=true spcount
- Mark as New
- Bookmark Message
- Subscribe to Message
- Mute Message
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Interesting. If I handed it to map, I'm afraid I'd be pinned to the limits of a subsearch, but it's an interesting idea.
I ended up doing something much like your example, but it's a pain, and certainly not easy to explain to anyone else.
What you absolutely can't do is something like this:
search ... | eval _time=fieldX | timechart fixedrange=false bins=100 count by fieldY
I believe it bins everything at some range relevant to the original query, which in my case ends up being a bin size of a second. So, you end up with thousands of bins.
I think I'd be set if I could do something like...
search ... | eval _time=fieldX | eventstats min(_time) as _search_earliest max(_time) as _search_latest | timechart fixedrange=100 bins=20 count by fieldY
- Mark as New
- Bookmark Message
- Subscribe to Message
- Mute Message
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content

If your sparkline are not dependent on timeseries data, you can use Pie sparkline instead (or bullet or box-plot).
Refer to my answers for other options available with sparklines: https://answers.splunk.com/answers/474127/pie-chart-sparkline-to-see-filling-ratio-of-splunk.html
PS: As informed, officially supported sparkline visualizations are only line, bar and area, but other sparklines from http://omnipotent.net/jquery.sparkline/#s-about, seem to work as well.
| makeresults | eval message= "Happy Splunking!!!"
- Mark as New
- Bookmark Message
- Subscribe to Message
- Mute Message
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
I am dependent on time data, but the time data isn't in the timeframe of the original query. The timeframe of the original query isn't relevant.
