Event Handler Reference
Use Simple XML event handler elements to create responsive dashboard behavior.
What is an event handler?
In web programming, event handlers let you listen for and define responses to state changes and user behavior, such as a mouse click or scroll. These changes or interactions are events. Event handlers in Simple XML work similarly.
Event handling contexts
Depending on the context, such as a form input or drilldown, the events that can happen and that are exposed in Simple XML elements vary. The use cases for handling events can also vary by context.
For example, in a form input, you can use the <change>
element that listens for a user selection and sets a token value based on that selection. This token value update can trigger panel show or hide behavior in the form, customizing the content to the selection.
Context | Events that happen in this context | Use case example |
---|---|---|
Form inputs | User selections or input | Customize the form content in response to user input values. |
Search states | A search has several state events, such as being in progress, cancelled, or done. | Use search event handlers to listen for search state changes and capture data or create dynamic behavior during different states. |
Drilldown | User clicks on a visualization where drilldown is enabled | Use drilldown to share additional data insights with your dashboard users. For example, you can open a secondary search or link to an external URL. |
Dashboard page load | Page loads in the browser window, displaying the dashboard | Set tokens on page load to manage initial display settings such as panel show or hide or search results for a visualization. |
Customizing responsive behavior
In some elements, you can define conditional responses to state changes. For example, you might want to handle particular search result field values differently when a search completes.
Tokens and event handlers
Use predefined or custom tokens to capture dynamic values or to help you implement responsive behavior. Depending on the context, available predefined tokens vary.
If you are unfamiliar with tokens, see Token usage in dashboards.
Form inputs
Respond to user input in any of the following form input elements.
-
<checkbox>
-
<dropdown>
-
<link>
-
<multiselect>
-
<radio>
-
<text>
-
<time>
Event handler element
Use the <change>
element to define responses to user selections in the input. You can include a <condition>
child element in <change>
to handle user input values conditionally.
<change>
element is not available for multiselect inputs.
<change>
<condition [label="foo" | value="foo" | match="(dashboard eval expression)"]>(0..n)
(<eval> | <link> | <set> | <unset>) (1..n)
For more details, see change in the Simple XML Reference.
Form input event tokens
Respond to user selections in a form input. Use predefined tokens to access the selected <choice>
element label or value.
Token | Description |
---|---|
label
| Selected <choice> element label.
|
value
| Selected <choice> element value.
|
Example Use the <change> element to capture the selected label and value from an input.
<form>
<label>Use tokens with input choices to capture input labels and values</label>
<fieldset submitButton="false">
<input type="radio" token="period_tok">
<label>Select a time range</label>
<choice value="-24h@h">Last 24 Hours</choice>
<choice value="-7d@d">Last 7 Days</choice>
<choice value="-30d@d">Last 30 Days</choice>
<default>Last 24 Hours</default>
<change>
<!-- use predefined input tokens to set -->
<!-- tokens for the selected label and value -->
<set token="date_label">$label$</set>
<set token="earliest_tok">$value$</set>
</change>
</input>
</fieldset>
<row>
<panel>
<title>Conditional Inputs</title>
<chart>
<!-- Display selected label in the title -->
<title>Source Type by $date_label$</title>
<search>
<query>index = _internal | timechart count by sourcetype</query>
<!-- use the value of earliest_tok -->
<!-- to set the time range -->
<earliest>$earliest_tok$</earliest>
<latest>now</latest>
</search>
<option name="charting.axisY.scale">log</option>
<option name="charting.axisTitleX.text">Time period</option>
<option name="charting.axisTitleY.text">Events</option>
</chart>
</panel>
</row>
</form>
Search event handlers
Search event handlers allow you to enable event actions based on search results or search properties. Actions include linking to a page, setting or unsetting tokens, and executing an eval function.
Search event tokens
Search event handlers use predefined tokens to access the search results and search properties. The tokens available to each handler vary. In some cases, the event handler does not access a predefined token to enable an action.
Token | Description |
---|---|
job.property |
Access the value of the named job property or one of its secondary properties. For example, use You can also view properties for a search from the Search Job Inspector. From the Search Page, after running a search select Job > Inspect Job. See View search job properties in the Search Manual for a list of properties available.
|
result.field |
Access the value of the named field. The token accesses the value from the first row of returned results. |
Search element syntax |
---|
|
For detailed information on search event tokens, see Define search tokens.
cancelled
<cancelled> |
---|
Execute actions when a search is cancelled. |
Parent element
<search> |
|
Tokens available
No tokens for this element. |
Example
|
error
<error> |
---|
Execute actions when there is a search error event, such as an invalid query. |
Parent element
<search> |
|
Tokens available
No tokens for this element. |
Example
|
fail
<fail> |
---|
Execute an action when a search fails while running. |
Parent element
<search> |
|
Tokens available
No tokens for this element. Only the failure message is available. |
Example
|
progress
<progress> |
---|
Execute an action on search progress events. Access job properties and the first results row. |
Parent element
<search> |
|
Tokens available
job.property result.field |
Example
|
done
<done> |
---|
Execute actions based on finished search events. |
Parent element
<search> |
|
Tokens available
job.property result.field |
Example
|
Visualization event handlers
<[Visualization]> | ||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|
Event handlers apply to the following visualization types:
| ||||||||||||
| ||||||||||||
Child elements
| ||||||||||||
Example
Example line chart panel using an inline search. It limits results to a specified time window and provides labels for the X and Y axes:
| ||||||||||||
|
Drilldown event tokens
For dynamic drilldown, there are predefined tokens available for each type of visualization. The value of a predefined token can vary, depending on the visualization.
chart (event tokens)
The clicked field name is the name of the field or series for the y-Axis if present (similar to click.name2). If the name of the field or series is not available the field or category for the x-axis is used (click.name).
Data Property | Description |
---|---|
click.name | Name of the field or category for the x-axis. Not available when the legend has been clicked. |
click.value | Value of the field or category for the x-axis. Not available when the legend has been clicked. |
click.name2 | Name of the field or series for the y-axis. |
click.value2 | Value of the field or series for the y-axis. Not available when the legend has been clicked. |
row.<fieldname> | Any field values along the y-axis at the same point as the click on the x-axis. Not available when the legend has been clicked. |
row.<x-axis-name> | Value of the x-axis. Not available when the legend has been clicked. |
earliest/latest | Time range of the clicked chart segment, or if not applicable, the time range of the search. |
event (event tokens)
The value for click.name
depends on the context of the click, as described below:
Data Property | Description |
---|---|
click.name | The field name associated with the click. For cases in the event viewer where the field name is ambiguous:
|
click.value | Value associated with the click. |
click.name2 | Identical to click.name . |
click.value2 | Identical to click.value . |
row.<fieldname> | Exposes each field value as row.<fieldname>. |
earliest/latest | Time range of the clicked event, which is: earliest: latest: |
map (event tokens)
The field for the <condition> tag in dynamic drilldown always corresponds to click.name.
Data Property | Description |
---|---|
click.name | Name of the first, or only field, that displays the marker. |
click.value | Value of the first, or only field, that displays the marker. |
click.name2 | Same as click.name. |
click.value2 | Same as click.value |
click.lat.name | Name of the latitude field that determines the location of the marker. |
click.lat.value | Latitude value of the geo location of the marker. |
click.lon.name | Name of the longitude field that determines the location of the marker. |
click.lon.value | Longitude value of the geo location of the marker. |
click.bounds.<orientation> | Outer boundaries of all clustered locations that the marker represents. Orientation: south, west, north, east |
row.<fieldname> | Each field value of the clicked marker is exposed in this form. |
earliest/latest | Time range of the search driving the map visualization. |
single (event tokens)
The field for the <condition> tag in dynamic drilldown always corresponds to click.name.
Data Property | Description |
---|---|
click.name | Name of the field that is displayed by the single value visualization. |
click.value | Value that is displayed by the single value visualization. |
click.name2 | Same as click.name. |
click.value2 | Same as click.value. |
row.<fieldname> | Exposes each field in the same result row from which the single value is taken. |
earliest/latest | Time range of the search driving the single value visualization. |
table (event tokens)
The field for the <condition> tag in dynamic drilldown always corresponds to click.name2.
Data Property | Description |
---|---|
click.name | Name of the leftmost field that is displayed in the table. This is always _time , if present. |
click.value | Value of the left-most column in the clicked row. |
click.name2 | Name of the clicked column. |
click.value2 | Value of the clicked column. |
row.<fieldname> | All field values for the clicked table row, including those fields that are not displayed. |
earliest/latest | Time range of the clicked table row, or if not applicable, the time range of the search. |
drilldown
<drilldown> | ||||||||
---|---|---|---|---|---|---|---|---|
Define custom destinations to link to when a user clicks on fields in a dashboard or form.
Specify a path to the destination using the <link> tag. Set or unset tokens using the <set> or <unset> tags. Specify a condition to specify fields for setting or unsetting tokens. Note: You can specify one or more actions (<eval>, <link>, <set>, <unset>) or conditions (<condition>) directly within <drilldown>, but you cannot specify both actions and conditions. | ||||||||
Attributes
| ||||||||
Parent elements
<chart> <event> <map> <single> <table> | ||||||||
| ||||||||
Example 1: Pass a value to a form
| ||||||||
Example 2: Pass parameters to a form
| ||||||||
Example 3: Pass a value from a chart to a website
|
selection
<selection> |
---|
Sets the time window for the pan and zoom feature of charts. You can also use tokens to set other values, such as the numerical values of the x-axis in a chart. Only applies to charts of type area, column, or line. See Chart controls for details on the pan and zoom feature of charts. |
Parent elements
<chart> <option name="charting.chart">area</option> | <option name="charting.chart">column</option> | <option name="charting.chart">line</option> |
Use pre-defined tokens to capture the earliest and latest time of the time window and the earliest and latest values within that time window for a field. For example:
Can also be used to set a drilldown link.
|
Attributes
No attributes for this element. |
Example
A selection on the left chart zooms into the right chart with details for the selected area.
|
|
Condition element
The <condition> element specifies the scope of actions based on one more conditions. The available conditions on which to base actions differ, depending on the parent element. The attributes available to the condition element vary, depending on the parent element.
Condition (input)
<condition> | ||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
Specifies the scope of actions based on input choices. If the parent element <change> is not present, then the actions apply to all choices. The <condition> element is not available for multiselect inputs. | ||||||||||||||||
Parent element
<input> <change> | ||||||||||||||||
| ||||||||||||||||
Attributes
| ||||||||||||||||
Example
Use conditional inputs to select preset time ranges for a search. The token for the selected choice appears in the title for the chart. The conditional token for the selected value drives the data for the chart.
| ||||||||||||||||
|
Condition (search)
<condition> | ||||||||
---|---|---|---|---|---|---|---|---|
Specifies a condition and behavior for when the condition is met. | ||||||||
Parent elements
<cancelled> | <done> | <error> | <fail> | <progress> | ||||||||
| ||||||||
Attributes
| ||||||||
Example
|
Condition (drilldown)
<condition> | ||||||||
---|---|---|---|---|---|---|---|---|
Limits the scope of drilldown actions to clicks on specific fields. If the <condition> element is not present, then drilldown actions apply to all fields. Note: The <condition> element applies to both input elements and drilldown elements. See <condition> (input) for details. | ||||||||
Parent element
<drilldown> | ||||||||
| ||||||||
Attributes
| ||||||||
Example See the example for <set> for using the <condition> tag to set a token for in-page drilldown. See the example for <unset> for using multiple <condition> tags. |
Event actions
eval
<eval> | ||||||||
---|---|---|---|---|---|---|---|---|
Executes an eval statement. An eval statement evaluates an expression and puts the results into a field. <eval> for dashboards works similarly, with some exceptions, to the SPL eval command. For more details, see eval in the Search Reference. | ||||||||
Parent elements
<drilldown><condition> <search><condition> <change><condition> | ||||||||
| ||||||||
Attributes
| ||||||||
Example
|
link
<link> | ||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
Specifies a link to a destination for drilldown or for a selected input choice. <link> can be a child tag of <change>, <drilldown>, <search>, or <condition>. Use <link> as a child tag of <condition> when you want to configure distinct drilldown actions for specific fields or inputs. Otherwise, use <link> as a child tag of <change> or <drilldown>. There are various ways to specify a destination for the drilldown using relative paths or a URL, as described below | ||||||||||||||||
Parent elements
<drilldown><condition> <search><condition> <change><condition>
| ||||||||||||||||
Attributes
| ||||||||||||||||
Parent element
| ||||||||||||||||
| ||||||||||||||||
Example
Use <link> with conditional inputs to open a new page.
|
set
<set> | |||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
Allows you to publish new global tokens that can be consumed by any other element or search within the dashboard. You typically publish tokens when using form inputs or when using drilldown. For form inputs, specify tokens for actions to take for specific inputs. For drilldown, specify the value to capture when clicked. The value can be set dynamically using a token. For form inputs, <set> can be a child tag of <change> or <condition>. For drilldown, <set> can be a child tag of <drilldown> or <condition>.Use <set> as a child tag of <condition> when you want to configure distinct actions for specific inputs or for fields for drilldown. Otherwise, use <set> as a child tag of <change> or <drilldown> to specify an action for all inputs or for all fields. | |||||||||||||||||
Parent elements
<change><condition> <drilldown><condition> <change> <drilldown> | |||||||||||||||||
There are two ways to set a value of a token.
| |||||||||||||||||
Attributes
| |||||||||||||||||
Example
A click on the table sets a token which is consumed by the search of the chart visualization.
|
unset
<unset> | ||||||||
---|---|---|---|---|---|---|---|---|
Use <unset> to remove a token that was previously set. | ||||||||
Parent elements
<change><condition> <drilldown><condition> <change> <drilldown> | ||||||||
| ||||||||
Attributes
| ||||||||
Example
Use <set> and <unset> to define the visualization to use. Use token definitions to hide a panel.
|