Document toolboxDocument toolbox

Calling an input value from a widget

For either type of input to work as a filter for a widget, the widget's query must reference the required input through a script. You must place the input script in the place the query references the values you want to filter by. Depending on the data to be entered in the input, you can use the following types of expressions: 

Query scriptSample widget queryResult

query(input_ID.value)

Use this expression as a placeholder for whole queries, for example:

  • from demo.ecommerce data where method = GET
query(
Input0.value)

Just enter the required query in the input with ID Input0 and the widget will display the query results immediately.

$input_ID.value

The $ operator enters the text specified in the input taking into account the format of the parameter to be replaced. This is used as a placeholder for specific values, which is mostly required in case of filter operations, for example:

  • 200
  • GET
query(
from demo.ecommerce.data
where method=$Input0.value)

The widget will represent all the events where the method is equal to the value entered in the input with ID Input0.

In this case, we must use $ to indicate that the text in the input is a specific value that must match the format of the method parameter.

$*input_ID.value

The $* operator enters the text specified in the input with no format, just as a string of characters. This is used as a placeholder for whole query parts, for example:

  • demo.ecommerce.data
  • group every 10m
query(
from $*Select0.value
group every $*Select1.value)

The widget will represent all the events from the data table entered in the input Select0 grouped by the period specified in the input Select1. 

In this case, we must use *$ to indicate that the text in the input is a part of a query, which must be entered as simple text with no format.

All widget and input ID values are assigned automatically and can be read in the Data settings of the widget or input element.

Examples

You can use multiple inputs simultaneously to generate a widget able to display different sets of data with just a few clicks. Below are some examples that may help you better understand the potential of inputs.

Example 1

Use the following query in a table widget to create a dynamic table that allows you to specify the source data table, the grouping period and the grouping key.

query(
from $*Select0.value
group every $*Select1.value
by $*Select2.value
select count() as count)

The table is linked to three different Select-type inputs populated with the following values:

Select0

["demo.ecommerce.data", "web.all.access"]

Select1

["2m", "5m", "1s"]

Select2

["statusCode", "method"]

The following capture shows the table after selecting demo.ecommerce.data as source table, 1s as grouping time and statusCode as key column for the grouping.

Example 2

Feed a column widget with the following query to display the count of status codes greater than a specified value and grouped by a period selected from a list of values.

query(
from demo.ecommerce.data
group every $*Select0.value
by statusCode where statusCode > $Input0.value
select count() as count)

The Select-type input is populated with the following values:

["5m", "10m", "15m"]

The following capture shows the column widget after selecting 5m as grouping time and entering 400 in the free-text input, so that only status codes greater than 400 are shown. You must select the count field as the Y-axis value and add the statusCode column as a series in the Visual settings of the column widget.