Hi,
I am having an issue trying to make a version of the search app filtering timeline work in my dashboard in Dashboard Studio with other visualizations. I have set a token interaction on click to update the global_time.earliest value as to the time that is clicked on the chart. I, however, am running into an issue where I cannot set the global_time.latest value by clicking again on the timechart. If I set up a second token interaction to get the latest time, it just sets it to the same as the earliest, all on the first click. I'm trying to filter it down to each bar's representation on the timechart, which is 2 hours ( |timechart span=2h ...).
Like the search apps version, this timechart is meant to be a filtering tool that will only filter down the search times of the other visualizations once it is set. Setting the earliest token works perfectly fine; it's all just about the latest. I just need to know how or if it is possible.
Thank you!!
Okay @datachacha
Ive been having a good think about this and I dont think I have an elegant solution - but I think I do have *a* solution:
This uses a hidden token/text box to the side and a search to determine the _time+2hours.
You can then use this in your other queries as earliest/latest as per the sample event on the dashboard using `$globalTimeSpl:results.earliest$` and `$globalTimeSpl:results.latest$`
Here is the full JSON to have a play around with - does this do what you need?
{
"title": "testing",
"description": "",
"inputs": {
"input_MPUmpGoR": {
"options": {
"defaultValue": "DEFAULT",
"token": "calc_earliest"
},
"title": "Earliest",
"type": "input.text"
},
"input_zIorjrMc": {
"options": {
"defaultValue": "-24h@h,now",
"token": "tr_global"
},
"title": "Main Time Selector",
"type": "input.timerange"
}
},
"defaults": {
"dataSources": {
"ds.search": {
"options": {
"queryParameters": {
"earliest": "-24h@h",
"latest": "now"
}
}
}
}
},
"visualizations": {
"viz_BcDlqy4I": {
"options": {
"markdown": "Earliest = $globalTimeSpl:result.earliest$ \nLatest = $globalTimeSpl:result.latest$"
},
"type": "splunk.markdown"
},
"viz_NgmH6lHI": {
"dataSources": {
"primary": "ds_BlYVOfBA"
},
"title": "This shows for time selected + 2hours",
"type": "splunk.table"
},
"viz_Nqdf4h2p": {
"dataSources": {
"primary": "ds_ccCiW2S8"
},
"eventHandlers": [
{
"options": {
"tokens": [
{
"key": "row._time.value",
"token": "calc_earliest"
}
]
},
"type": "drilldown.setToken"
}
],
"type": "splunk.column"
},
"viz_zUx2Zt29": {
"dataSources": {
"primary": "ds_ZKBDXZy2_ds_BlYVOfBA"
},
"type": "splunk.table"
}
},
"dataSources": {
"ds_BlYVOfBA": {
"name": "global",
"options": {
"query": "index=_internal earliest=$globalTimeSpl:result.earliest$ latest=$globalTimeSpl:result.latest$ \n| addinfo \n| head 1\n| table info* _raw"
},
"type": "ds.search"
},
"ds_ZKBDXZy2_ds_BlYVOfBA": {
"name": "globalTimeSpl",
"options": {
"enableSmartSources": true,
"query": "| makeresults \n| addinfo\n| eval earliest=IF($calc_earliest|s$!=\"DEFAULT\",$calc_earliest|s$,info_min_time)\n| eval latest=IF($calc_earliest|s$!=\"DEFAULT\",$calc_earliest$+7200, info_max_time)",
"queryParameters": {
"earliest": "$tr_global.earliest$",
"latest": "$tr_global.latest$"
}
},
"type": "ds.search"
},
"ds_ccCiW2S8": {
"name": "tstat",
"options": {
"query": "| tstats count where index=_internal by _time span=1h",
"queryParameters": {
"earliest": "$tr_global.earliest$",
"latest": "$tr_global.latest$"
}
},
"type": "ds.search"
},
"ds_rt307Czb": {
"name": "timeSPL",
"options": {
"enableSmartSources": true,
"query": "| makeresults \n| addinfo",
"queryParameters": {
"earliest": "-60m@m",
"latest": "now"
}
},
"type": "ds.search"
}
},
"layout": {
"globalInputs": [
"input_zIorjrMc"
],
"layoutDefinitions": {
"layout_1": {
"options": {
"display": "auto",
"height": 960,
"width": 1440
},
"structure": [
{
"item": "viz_Nqdf4h2p",
"position": {
"h": 300,
"w": 1390,
"x": 10,
"y": 210
},
"type": "block"
},
{
"item": "viz_NgmH6lHI",
"position": {
"h": 140,
"w": 1390,
"x": 10,
"y": 60
},
"type": "block"
},
{
"item": "viz_BcDlqy4I",
"position": {
"h": 50,
"w": 300,
"x": 20,
"y": 10
},
"type": "block"
},
{
"item": "input_MPUmpGoR",
"position": {
"h": 82,
"w": 198,
"x": 1470,
"y": 50
},
"type": "input"
},
{
"item": "viz_zUx2Zt29",
"position": {
"h": 100,
"w": 680,
"x": 1470,
"y": 130
},
"type": "block"
}
],
"type": "absolute"
}
},
"tabs": {
"items": [
{
"label": "New tab",
"layoutId": "layout_1"
}
]
}
}
}
🌟 Did this answer help you? If so, please consider:
Your feedback encourages the volunteers in this community to continue contributing
Thank you for the timely response. I tried what you recommended and ran into a few issues that I was not able to diagnose or fix with the troubleshooting tips provided.
I got everything looking exactly as you said. However, $result._time$ doesn't seem to evaluate to a time whatsoever; when I check the value, it is literally just "$result._time$". The latest time value gets set to "relative_time(-7d@h", which appears incomplete as shown.
I get an error on the visualization saying Invalid earliest_time, and both earliest and latest show invalid values.
When I tried to put in the troubleshooting eval command you recommended, it did not fix the issue. The time should be coming in correctly.
Thank you very much for this solution however my needs need to have it as streamlined as possible. While this does give the essential functionality that I need, it is a solution I need to work off of additionally. My needs specifically are that it is all click based and you don't have to change anything anywhere else and that it can all be handled within the timechart/bar chart. Anything else is to be fully hidden away.
Much like the search app counterpart I also needed the timechart to the update itself based on the time range the rest of the visualization would use. Ideally this would just zoom in on one bar. Unfortunately what I am trying to and what I am trying to make altogether can't have the Text box and specific manual inputs.
Simply put, this does accomplish the goal of setting time earliest and latest values that are 2h apart and then the other visualizations can take those tokens as their time. But I need a different approach to getting there.
index=your_index earliest=$global_time.earliest$ latest=$global_time.latest$ | ...
{ "visualizations": { "viz_timechart": { "type": "splunk.timechart", "options": { ... }, "dataSources": { "primary": "ds_timechart" }, "eventHandlers": [ { "type": "drilldown.setToken", "options": { "token": "global_time.earliest", "value": "$result._time$" } }, { "type": "drilldown.setToken", "options": { "token": "global_time.latest", "value": "relative_time($global_time.earliest$, \"+2h\")" } } ] } } }
Please can you confirm if you were able to test and have working the example and process provided?
Unfortunately this reads a lot like an AI hallucination because it looks to mix Classic XML and Dashboard Studio approaches to tokens. For example it is not possible to put $ into the value field for a token, and it should be row._time.value not $result._time$
If you have this as a working approach then please can you share a working version as I wasnt aware it was possible to do evals in drilldown.setToken
🌟 Did this answer help you? If so, please consider:
Your feedback encourages the volunteers in this community to continue contributing
Ok, thank you. I thought there was something up with the $'s; they would accept it as a static value instead of a predefined token when setting them up in the interactions menu, but the logic wouldn't work. And it seems to be the case as well for the second, the eval statement just did not work at all as intended.
I was wondering why this didn't work.