In Dashboard Studio, a single click interaction on the timechart can set both global_time.earliest (the start of the clicked bar) and global_time.latest (the end of the 2-hour bar) by using a token formula. Instead of relying on a second click, you’ll compute global_time.latest as global_time.earliest + 2 hours. This ensures the exact 2-hour range is applied to other visualizations, mimicking the Search app’s timeline filtering. This is assuming that you want 2 hour chunks. You can get crazy and tokenize the span=2h and then use that same token in the example I provide, but that is not the solution I am providing below. Steps to Implement Verify Your Timechart Configuration: Ensure your timechart uses a 2-hour span, as you mentioned (| timechart span=2h ...). This means each bar represents a 2-hour bucket (e.g., 10:00–12:00, 12:00–14:00). In Dashboard Studio, confirm the visualization is set up as a Timechart (Area, Column, or Line) under the Visualization tab. Set the global_time.earliest Token: You’ve already set a token interaction for global_time.earliest, but let’s confirm it’s correct. In Dashboard Studio’s UI Editor: Select your timechart visualization. Go to the Interactions tab in the configuration panel. Under On Click, add a Set Token action: Token Name: global_time.earliest Token Value: $result._time$ (this captures the start time of the clicked bar, e.g., 10:00 for a 10:00–12:00 bar). This sets global_time.earliest to the timestamp of the clicked bar’s start. Calculate global_time.latest Token: Instead of a second click, compute global_time.latest as global_time.earliest + 2 hours using a token formula. In the UI Editor: Go to the same On Click interaction for the timechart. Add a second Set Token action (below the global_time.earliest one): Token Name: global_time.latest Token Value: relative_time($global_time.earliest$, "+2h") This uses Splunk’s relative_time function to add 2 hours to the earliest timestamp (e.g., if earliest is 10:00, latest becomes 12:00). Both tokens will now be set on a single click, defining the exact 2-hour range of the clicked bar. Apply Tokens to Other Visualizations: Ensure other visualizations in your dashboard use the global_time.earliest and global_time.latest tokens to filter their time ranges. For each visualization (e.g., table, chart): Go to the Search tab in the configuration panel. Set the Time Range to Custom and use: Earliest: $global_time.earliest$ Latest: $global_time.latest$ Alternatively, modify the search query directly to include the token-based time range, e.g.: spl index=your_index earliest=$global_time.earliest$ latest=$global_time.latest$ | ... Add a Default Time Range (Optional): To prevent visualizations from breaking before a timechart click, set default values for the tokens. In the UI Editor: Go to the Dashboard configuration (top-level settings). Under Tokens, add: Token Name: global_time.earliest, Default Value: -24h@h (e.g., last 24 hours, snapped to hour). Token Name: global_time.latest, Default Value: now (current time). This ensures other visualizations display data until the timechart is clicked. Test the Dashboard: Save and preview the dashboard. Click a timechart bar (e.g., representing 10:00–12:00). Verify that: global_time.earliest is set to the bar’s start (e.g., 10:00). global_time.latest is set to the bar’s end (e.g., 12:00). Other visualizations update to show data only for that 2-hour range. Use the Inspect tool (click the three dots on a visualization > Inspect > Tokens) to debug token values if needed. Why This Works Single Click: Using relative_time($global_time.earliest$, "+2h") avoids the need for a second click, as it calculates the end of the 2-hour bar based on the clicked time. Mimics Search App: The Search app’s timeline sets both earliest and latest times for a selected range. This solution replicates that by defining the full 2-hour bucket. Dashboard Studio Limitation: Dashboard Studio doesn’t natively support range selection (like dragging over a timeline), so computing latest via a formula is the best approach. Troubleshooting Tips Tokens Not Setting: If global_time.latest isn’t updating, check the token syntax in the Source view (JSON). Ensure the relative_time function is correct: "value": "relative_time($global_time.earliest$, \"+2h\")". Time Format Issues: Ensure $result._time$ returns a timestamp in epoch format (seconds). If not, use strptime in the timechart search to format it, e.g., | eval _time=strptime(_time, "%Y-%m-%d %H:%M:%S"). Visualization Not Updating: Confirm other visualizations reference $global_time.earliest$ and $global_time.latest$ correctly. Check their search queries in the Source view. Span Mismatch: If the timechart span changes (e.g., dynamically set), you may need to make the +2h offset dynamic. Let us know if your span varies for a custom solution. Example JSON Snippet (Source View) For reference, here’s how the timechart’s interaction might look in the dashboard’s JSON (edit in Source view if needed): json {
"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\")"
}
}
]
}
}
}
... View more