Time range

You can add time range pickers to your dashboard, which allow dashboard viewers to select a time range to define the token associated with that time range picker. You can associate the time range tokens with data sources to display data for certain time ranges.

The time range input dropdown that provides options for setting the time range.

Global time range picker

The global time range picker is unique from other time range pickers because all new dashboards include it by default. The global time range picker can control all ds.search searches. The global time range picker controls all searches by adding settings in the defaults section of the dashboard definition. To learn about dashboard defaults for data sources, see Defaults for data sources and visualizations.

To use different time ranges for various data sources, you can modify or delete the default global time range picker and/or create other time range pickers.

Delete the global time range picker

You can delete or edit the global time range picker. To delete it, do the following:

  1. In the visual editor, select the global time range picker, then click the X in its upper right corner. This removes the input from the visual editor, the dashboard definition, and the layout.
  2. Manually delete the time range tokens in the defaults section using the source editor. Delete queryParameters and the related settings:
    "defaults": {
    	"dataSources": {
    		"global": {
    			"options": {
    				"queryParameters": {
    					"latest": "$global_time.latest$",
    					"earliest": "$global_time.earliest$"
    				}
    			}
    		}
    	},
If you delete the global time range picker only using the source editor, remember to remove it from the globalInputs section of the layout, the queryParameters, and the related settings in the defaults section.

Dashboard definition example with global and custom time range pickers

The following example shows a dashboard with 4 inputs: the default global time range picker, a custom time range picker, a dropdown, and a multiselect, and 2 line charts: Activity by Status for Global Time Range and Activity by Status for Custom Time Range.

The 2 line charts are configured to display the same data but for different time ranges. Note that the data source for the Activity by Status for Custom Time Range chart is explicitly configured to use the time range defined by the Custom Time Range picker. The data source for the Activity by Status for Global Time Range chart is configured to use the default time range, which is the time range defined by the Global Time Range picker.

Copy and paste the dashboard definition into your own dashboard to see the example. Note that in the defaults stanza, ds.search data sources are configured to use the global time range picker settings.

{
    "title": "Time range picker examples",
    "description": "",
    "inputs": {
        "input_08lrAW9u": {
            "context": {
                "formattedConfig": {
                    "number": {
                        "prefix": ""
                    }
                },
                "formattedStatics": ">statics | formatByType(formattedConfig)",
                "label": ">primary | seriesByName(\"method\") | renameSeries(\"label\") | formatByType(formattedConfig)",
                "statics": [
                    [
                        "All"
                    ],
                    [
                        "*"
                    ]
                ],
                "value": ">primary | seriesByName(\"method\") | renameSeries(\"value\") | formatByType(formattedConfig)"
            },
            "dataSources": {
                "primary": "ds_ljNWYr7J"
            },
            "options": {
                "defaultValue": "*",
                "items": ">frame(label, value) | prepend(formattedStatics) | objects()",
                "token": "method"
            },
            "title": "Select Method",
            "type": "input.dropdown"
        },
        "input_RhQr1bEx": {
            "context": {
                "formattedConfig": {
                    "number": {
                        "prefix": ""
                    }
                },
                "formattedStatics": ">statics | formatByType(formattedConfig)",
                "label": ">primary | seriesByName(\"status\") | renameSeries(\"label\") | formatByType(formattedConfig)",
                "statics": [
                    [
                        "All"
                    ],
                    [
                        "*"
                    ]
                ],
                "value": ">primary | seriesByName(\"status\") | renameSeries(\"value\") | formatByType(formattedConfig)"
            },
            "dataSources": {
                "primary": "ds_neN4LNL4"
            },
            "options": {
                "defaultValue": "*",
                "items": ">frame(label, value) | prepend(formattedStatics) | objects()",
                "token": "status"
            },
            "title": "Select Status Code",
            "type": "input.multiselect"
        },
        "input_Y8d7RBfE": {
            "options": {
                "defaultValue": "-30d@d,now",
                "token": "tr_XeZ2dKeI"
            },
            "title": "Custom Time Range",
            "type": "input.timerange"
        },
        "input_global_trp": {
            "options": {
                "defaultValue": "-24h@h,now",
                "token": "global_time"
            },
            "title": "Global Time Range",
            "type": "input.timerange"
        }
    },
    "defaults": {
        "dataSources": {
            "ds.search": {
                "options": {
                    "queryParameters": {
                        "earliest": "$global_time.earliest$",
                        "latest": "$global_time.latest$"
                    }
                }
            }
        }
    },
    "visualizations": {
        "viz_1BAm6ljX": {
            "dataSources": {
                "primary": "ds_6v2nFTBZ"
            },
            "description": "Select Method and Status Codes",
            "showLastUpdated": false,
            "showProgressBar": false,
            "title": "Activity by Status for Custom Time Range",
            "type": "splunk.line"
        },
        "viz_uhDaw5WM": {
            "dataSources": {
                "primary": "ds_aUefmET4"
            },
            "description": "Select Method and Status Codes",
            "showLastUpdated": false,
            "showProgressBar": false,
            "title": "Activity by Status for Global Time Range",
            "type": "splunk.line"
        }
    },
    "dataSources": {
        "ds_6v2nFTBZ": {
            "name": "Status codes per method custom time range",
            "options": {
                "query": "index=_internal method=\"$method$\" \n| search status IN ($status$)\n| timechart count by status",
                "queryParameters": {
                    "earliest": "$tr_XeZ2dKeI.earliest$",
                    "latest": "$tr_XeZ2dKeI.latest$"
                }
            },
            "type": "ds.search"
        },
        "ds_aUefmET4": {
            "name": "Status codes per method global time range",
            "options": {
                "query": "index=_internal method=\"$method$\" \n| search status IN ($status$)\n| timechart count by status"
            },
            "type": "ds.search"
        },
        "ds_ljNWYr7J": {
            "name": "Method",
            "options": {
                "query": "index=_internal \n|  stats count by method"
            },
            "type": "ds.search"
        },
        "ds_neN4LNL4": {
            "name": "Status",
            "options": {
                "query": "index=_internal \n| stats count by status"
            },
            "type": "ds.search"
        }
    },
    "layout": {
        "globalInputs": [
            "input_global_trp",
            "input_Y8d7RBfE",
            "input_08lrAW9u",
            "input_RhQr1bEx"
        ],
        "layoutDefinitions": {
            "layout_1": {
                "structure": [
                    {
                        "item": "viz_uhDaw5WM",
                        "position": {
                            "h": 400,
                            "w": 584,
                            "x": 0,
                            "y": 0
                        },
                        "type": "block"
                    },
                    {
                        "item": "viz_1BAm6ljX",
                        "position": {
                            "h": 400,
                            "w": 616,
                            "x": 584,
                            "y": 0
                        },
                        "type": "block"
                    }
                ],
                "type": "grid"
            }
        },
        "tabs": {
            "items": [
                {
                    "label": "New tab",
                    "layoutId": "layout_1"
                }
            ]
        }
    }
}