Inputs & Tokens
I've gotta say we've got a pretty good looking dashboard coming along so far, but there is more of the journey left still my apprentice.
What if I told you that you can actually make dashboards dynamic
?! There are many who aren't as trained in The Force Cribl Search as you are. Creating dynamic dashboards
is a great way to give those users access to the analytics they need, and even allow them to manipulate the data presented, without knowledge of the Cribl Search language. This is done using inputs
and tokens
.
Inputs
Inputs
help constrain the view of visualization panels
in a dashboard
by linking them to specific data sources
. When you save an input
, a new input box
at the top of your dashboard
displays values related to the input
you created. Selecting options in the input box
changes the display of data in any linked visualizations
. There are several types of inputs
available to you.
Dropdown
Dropdown inputs
allow users to choose from a list of values you’ve specified to constrain linked visualization panels
to those values. The list of values can be static
(where you type all options available to the user), or dynamic
(where the results of a search provide the values of the dropdown).
Time Range
The Time Range input
allow users to limit any visualization
in a dashboard
to a specific time period
. In essence this is a time picker
for your dashboard
. Changing the time
in the time input
only affects the panels
configured to reference the input. All other panels
will continue to use the time range configured within their panels.
Text
The Text input
enables users to enter freeform text
so that linked visualization panels
display only data with that text value
. Think of this as a fancy free-text search box.
Number
The Number input
allows users to enter a number
. Optionally, you can enter a default value
and minimum
and maximum
values.
Adding Inputs
It's time to supercharge this dashboard
with a few inputs
.
- While in
Edit
mode, click theAdd
dropdown. - Click
Input
. - For
Type
ensureDropdown
is selected. - For the
Title
enterProvider Types
. - For
input_ID
enterprovider_type
.tipThe
input_ID
is how you will reference thisinput
when linkingpanels
to theinput
. Everyinput
must have aninput_ID
. By default, a genericinput_ID
is populated, but using adescriptive input_ID
(containingalphanumeric characters
,underscores
, andhyphens
only) is highly recommended as it makes it easier to know what eachinput
is used for. - For the
HOW TO POPULATE THE DROPDOWN
option selectRun a Search
. - In the
query box
enter:dataset="$vt_datasets"
| project provider.type
| distinct provider_type
| sort by provider_type asc - For the
Field name
typeprovider_type
. - For the
Default value
field enter*
. - Toggle
Multiselect
toYes
. - Click
Search
. - Close the
Edit
modal. - Click
Save
.
At this point, the input
will have been added to the top of your dashboard
. You can click the dropdown
on your input
to see if results are showing up as expected. For this input
, we are using a query that lists all of our datasets
and telling our dropdown input
to use the id
field from our query
as the list of values
for the input
. If configured correctly we should be able to see a list of datasets
when we expand the dropdown
.
Tokens
Once the input
is configured it must be linked
to the panels
that you would like to have leverage the input's value
. This is where tokens
come into play. The token
is essentially a variable
that stores the input value
. Anywhere the token
is placed in a query
will be replaced with the actual value
of the input
that corresponds to that token
. If the input value
changes, so does the token value
.
The format of a token
in the input's ID
surrounded by the $
character. For example, the token that we would need to use for the provider_type
input that we created would be $provider_type$
.
To make use of our new input
let's add the token
to a couple of panels
.
- Click the
edit
icon at the top right of the
Datasets per Provider
panel. - Replace the query with:
dataset="$vt_datasets" id in ("cribl*", "default*") provider.type in($provider_type$)
| summarize datasets=dcount(id) by provider.typenoteThe change that we've made here is we've added
provider.type in($provider_type$)
after ourid
filter. This will replace ourtoken
of$provider_type$
with whatever we select from ourinput
, effectivelyfiltering
our entire result set to ourinput's value
. - Click
Search
. - Close the
Edit
modal. - Click
Save
. - Click the
edit
icon at the top right of the
Datasets
panel. - Replace the query with:
dataset="$vt_datasets" id in ("cribl*", "default*") provider.type in($provider_type$)
| project dataset=id, description - Click
Search
. - Close the
Edit
modal. - Click
Save
.
Let's see how we did!
- Clear the contents of the
Provider Types
dropdown. - Select 2-3
provider types
. - Click
Apply
.
And voila! Both panels
should now show updated results that only apply to the selected provider types
.
Adding a Time Range Input
Using the time range
input type has a slightly different workflow.
- While in
Edit
mode, click theAdd
dropdown. - Click
Input
. - For
Type
selectTime Range
. - For the
Title
enterTime Range
. - For the
input_ID
entertimepicker
. - Close the
Edit
modal.
Now we've added a Time Range input
to our dashboard
. To visually show it's functionality we'll create a new panel that is better suited for showing data over time.
- While in
Edit
mode, click theAdd
dropdown. - Click
Visualization
. - For the
Title
enterSearches by Dataset
. - In the
query box
enter:dataset="$vt_jobs"
| project _time, id, dataset=resolvedDatasets
| mv-expand dataset
| timestats searches=dcount(id) by dataset - Click
Search
. - For the
Type
selectArea
. - Above the
query box
, click thetime unit
(ie. hour ago, days ago, etc.). - Click the
Link
tab. - For
Time range input
selectTime Range
(this is theinput
we just created). - Click
Apply
. - Close the
Edit
modal. - Click
Save
.
Awesome job. Let's take it for a spin.
- Click the
Time Range
input. - Change the
time
from1 hour ago
to6 hours ago
. - Click
Apply
.
You can see our Searches by Dataset
panel has magically updated to reflect the longer time period.