You need to enable JavaScript to run this app.
Torch Log Service

Torch Log Service

Copy page
Download PDF
Add dashboard filters and variables
Add custom variables to dashboard
Copy page
Download PDF
Add custom variables to dashboard
This topic describes how to add custom variables to a dashboard and provides related examples.​
Prerequisites​
  • Log data has been collected and indexes are configured. For more details, see Collect log data.​
Notice​
The total number of filters, variables, and charts in each dashboard must not exceed 50.​
Steps to add custom variables​
  1. Log in to TLS console.​
  1. Select the region where log service is located from the top navigation bar.​
  1. In the left navigation bar, select Common functions > Dashboard.​
  1. In the dashboard list, click the dashboard under the target project.​
  1. Click the settings icon in the upper right corner of the page.​
  • ​​​
  1. On the Filters and variables tab, click Add custom variable.​
  1. In the Add custom variables panel, configure the following parameters, click Create variables, and then click Save.​
  • ​
    Configuration​
    Description​
    Variable​
    The variable name used for filtering.​
    The log service uses this variable as the key for filtering conditions, which takes effect on the statistical charts in the dashboard that have this variable configured.​
    Variable alias (display name)​
    Alias for the variable name. For example, you can set an alias Client IP for the variable clientIP to enhance the dashboard experience.​
    Static value​
    Set a static value for the variable. TLS will add this static value to the value list of the specified variable. You can add multiple static values, and adjust their order by dragging the text box. You can add the following configurations for each static value:​
    • Field value: The variable value used for filtering. It is a required parameter. Supports setting as an asterisk (*), which matches all variable values.​
    • Field value alias: Alias for the variable value. It is not required. For example, set the alias Zhang San for the variable value zhangsan.​
    • Default selection: Whether this field is selected by default in the variable. By default, this feature is disabled, which means it is not selected. When multiple selection support is not enabled, only one value can have default selection enabled.​
    Dynamic value​
    Set a dynamic value for the variable. TLS uses the query and analysis results of the selected log topic as optional variable values.​
    Dynamic values change dynamically, and their actual values depend on factors such as the selected time range and query and analysis statements.​
    ​
Example: Add a time interval variable​
For example, Chart A displays the number of requests per minute. When you need to view website traffic at different time intervals (such as per second, per hour, etc.), you can manually add a time interval variable placeholder in the query and analysis statement. Then, use the variable to filter chart data.​
  1. Add a chart.​
  • Add chart A to the dashboard before adding custom variables. For detailed instructions, see Add charts to dashboard. The query and analysis statement for chart A is as follows:​
  • ​
    * | SELECT DATE_FORMAT(__time__ - __time__ % 60000, 'HH:mm:ss') AS time, count(*) AS PV GROUP BY time ORDER BY time​
    ​
Notice​
__time__ is a timestamp in milliseconds. Therefore, DATE_FORMAT(__time__ - __time__ % 60000, 'HH:mm:ss') means that the time will be aligned to the nearest minute.​
  • ​​​
  1. Edit the query and analysis statement for chart A and add a variable placeholder ${{interval|60000}} in the statement.​
  • ​
    * | SELECT DATE_FORMAT(__time__ - __time__ % ${{interval|60000}}, 'HH:mm:ss') AS time, count(*) AS PV GROUP BY time ORDER BY time​
    ​
  • ​​​
  1. Add a variable.​
  • Here are examples of important configuration items:​
  • Set variable name to interval.​
  • Set variable alias (display name) to Time interval.​
  • Set static value of field to 3600000, 60000, and 1000, representing intervals of per hour, per minute, and per second respectively.​
  • ​​​
  1. Save configurations.​
  • At the top right of the Settings page, click Save.​
  • ​​​
  1. Use variables.​
  • After you add a variable, a variable selection box is displayed in the dashboard. You can filter chart data using the variable selection box. For example, if you select time interval as hour, Chart A displays the number of website visits each hour.​
  • ​​​
Related operations​
After you add filters and variables, you can use them in the dashboard, or you can modify and delete them as needed. For details, see Common dashboard actions.​
​
Last updated: 2026.03.11 18:49:43