tencent cloud

Feedback

Filters and Variables

Last updated: 2024-01-20 17:31:31

    Type Description

    Type
    Description
    Scope
    Filter in the drop-down list
    Filter data in all charts on the dashboard by specifying the field value. If statistics is enabled in the index configuration of the log topic for the filter field, the field value can be automatically obtained as a list item.
    All charts on the dashboard
    Filter by search statement
    Filter data in all charts on the dashboard by entering a search statement, that is, add a filter in the query statement of the charts.Filter by search statement includes filter by range, NOT, and full text.
    All charts on the dashboard
    Data source variable
    A data source variable enables batch switching data sources of the charts on the dashboard. It is applicable to scenarios such as applying a dashboard to multiple log topics and comparing data in blue and green on the dashboard.
    Charts that use the variable on the dashboard
    Custom variable
    A custom variable can be set to a static input or a value from a dynamic query and applied to search statements, titles, and text charts for quick batch statement modification.
    Charts that use the variable on the dashboard

    Filter

    Configuring the filter in the drop-down list

    1. Log in to the CLS console.
    2. On the left sidebar, click Dashboard to enter the dashboard management page.
    3. Click the ID/name of the target dashboard to enter the dashboard details page.
    4. Click Add Filter and Variable at the top to enter the settings page.
    5. In the pop-up window, configure the filter in the drop-down list and click OK.
    Form Element
    Description
    Type
    Different types correspond to different configuration items and application scenarios. Here, select **Filter in the drop-down list**.
    Filter alias
    It is the filter name displayed on the UI, which is optional. If it is left empty, the filter field will be used automatically.
    Log topic
    It is the log topic to which the filter field belongs.
    Filter field
    It is the object field to be filtered.
    Dynamic option
    After it is enabled, the filter field value will be obtained automatically as the filter option.
    Static option
    A static option is optional, needs to be added manually, and will be always displayed. You can configure its alias.
    Default filter
    It is the default filter of the dashboard and is optional.
    Support for multiple items
    After it is enabled, multiple filters can be selected as the filter condition.
    6. Go back to the dashboard details page, click the filter icon, and select the target filter. Then, the dashboard data will be refreshed to the filtered content.

    Configuring filter by search statement

    1. Log in to the CLS console.
    2. On the left sidebar, click Dashboard to enter the dashboard management page.
    3. Click the ID/name of the target dashboard to enter the dashboard details page.
    4. Click Add Filter and Variable at the top to enter the settings page.
    5. In the pop-up window, set the information of the filter by search statement and click Submit.
    Form Element
    Description
    Type
    Different types correspond to different configuration items and application scenarios. Here, select **Filter by search statement**.
    Filter name
    It is the unique filter name.
    Filter alias
    It is the filter name displayed on the UI, which is optional.
    Log topic
    It is the log topic to which the filter field belongs.
    Mode
    It is the mode for inputting search statements. Here, interactive and statement modes are supported.
    Default filter
    It is the default filter of the dashboard and is optional.
    6. Go back to the dashboard details page, click the filter icon, and select the target filter. Then, the dashboard data will be refreshed to the filtered content. Filter by search statement includes filter by range, NOT, and full text.

    Variable

    Configuring the data source variable

    1. Log in to the CLS console.
    2. On the left sidebar, click Dashboard to enter the dashboard management page.
    3. Click the ID/name of the target dashboard to enter the dashboard details page.
    4. Click Add Filter and Variable at the top to enter the settings page.
    5. In the pop-up window, configure the template variable information and click Submit.
    Form Element
    Description
    Variable type
    It is the variable type. Different types correspond to different configuration items and application scenarios. Here, select **Data source variable**.
    Variable name
    It is the name of the variable in the search statement and can contain only letters and digits.
    Displayed name
    It is the variable name displayed on the dashboard, which is optional. If it is empty, the variable name will be used automatically.
    Data source scope
    It is the optional scope of the variable value and defaults to **All Log Topics**. You can select **Custom Filter** and set a filter to view only log topics that meet the condition.
    Default log topic
    It is the default log topic.
    6. Go back to the dashboard details page and click More > Edit Chart.
    Note:
    If there are no charts on your dashboard, add charts.
    7. On the Search Statement tab of Edit Chart, click Log Topic, select Use Data Source Variable, and select the created template variable.
    8. Click Save.
    9. On the dashboard details page, click the Data Source drop-down list and select another log topic. Then the system changes automatically changes the data source of the chart using the variable accordingly.

    Configuring the custom variable

    1. Log in to the CLS console.
    2. On the left sidebar, click Dashboard to enter the dashboard management page.
    3. Click the ID/name of the target dashboard to enter the dashboard details page.
    4. Click Add Filter and Variable at the top to enter the settings page.
    5. In the pop-up window, set the information of the custom variable and click Submit.
    Form Element
    Description
    Type
    It is the variable type. Different types correspond to different configuration items and application scenarios. Here, select **Data source variable**.
    Variable name
    It is the name of the variable in the search statement and can contain only letters and digits. A variable is referenced in the format of ${Variable name}.
    Variable alias
    It is the variable name displayed on the dashboard, which is optional. If it is empty, the variable name will be used automatically.
    Static variable value
    A static variable value needs to be added manually and will be always displayed. You can configure its alias.
    Dynamic variable value
    After it is enabled, you can select a log topic, enter a search and analysis statement, and use the search and analysis result as the optional variable value.
    Default value
    The default value is the variable value and is required.
    6. Go back to the dashboard details page and click More > Edit Chart.
    Note:
    If there are no charts on your dashboard, add charts.
    7. On the Search Statement tab of Edit Chart, insert the created custom variable ${interval} to replace the original text.
    8. Click Apply to Dashboard.
    9. Go back to the dashboard details page, click the Time Granularity drop-down list at the top, and change the time granularity. Then, you can see that the charts inserted with the variable change accordingly.

    FAQs

    Why does a configured data source variable not take effect or take effect only on some charts? A data source variable does not apply directly to all charts on the dashboard. It applies only to those charts that use it on the chart editing page.

    Examples

    Analyzing the performance metrics of different application APIs on the dashboard (filter in the drop-down list)

    Requirement

    Log topic A stores NGINX access logs of an application, and you are to use the dashboard to view the throughput, number of error requests, and response time of the entire application and a specified API. The following is the sample log information:
    body_bytes_sent:1344
    client_ip:127.0.0.1
    host:www.example.com
    http_method:POST
    http_referer:www.example.com
    http_user_agent:Mozilla/5.0
    proxy_upstream_name:proxy_upstream_name_4
    remote_user:example
    req_id:5EC4EE87A478DA3436A79550
    request_length:13506
    request_time:1
    http_status:201
    time:27/Oct/2021:03:25:24
    upstream_addr:219.147.70.216
    upstream_response_length:406
    upstream_response_time:18
    upstream_status:200
    interface:proxy/upstream/example/1

    Solution

    1. Create a dashboard.
    2. Create three charts (sequence diagrams) based on the application performance metrics. The corresponding query statements are as follows:
    Throughput
    * | select histogram( cast(__TIMESTAMP__ as timestamp),interval 1 minute) as analytic_time, count(*) as pv group by analytic_time order by analytic_time limit 1000
    Number of error requests
    http_status:>=400 | select histogram( cast(TIMESTAMP as timestamp),interval 1 minute) as analytic_time, count(*) as pv_lost group by analytic_time order by analytic_time limit 1000
    Average response time
    * | select histogram( cast(TIMESTAMP as timestamp),interval 1 minute) as analytic_time, avg(request_time) as response_time group by analytic_time order by analytic_time limit 1000
    3. Add a filter in the drop-down list.
    Type: Filter in the drop-down list
    Display Name: API name
    Log Topic: Log topic A
    Select field: interface
    4. Go back to the dashboard details page, and you can see this variable on the top of the page.
    If API Name is not specified, data is not filtered, and the charts on the dashboard display all data, that is, the overall performance metrics of the application.
    If API Name is specified, all charts on the dashboard use the specified API as the filter condition to filter data and display the performance metrics of the API.

    Viewing the production and test environment performance metrics on the dashboard separately (data source variable)

    Requirement

    An application has a production environment and a test environment, and logs are collected to Log topic A (production environment) and Log topic B (test environment). Therefore, during application development, testing, and Ops, you need to pay attention to the performance metrics of the two environments.

    Solution

    1. Create a dashboard.
    2. Add variables.
    Variable Type: Data Source
    Variable Name: env
    Display Name: Application Environment
    Data Source Scope: All log topics
    Default Log Topic: Log topic A (production environment)
    3. Add charts. In the Log Topic drop-down list, select Use Data Source Variable and select the ${env} variable created in the previous step. Then, charts will use the value of the variable as the data source, that is, Log topic A (production environment).
    4. Repeat Step 3 to add other charts.
    5. Go back to the dashboard details page, click the data source variable Application Environment at the top of the page, and switch the log topic in the drop-down list of the variable. Then, the charts that use the variable will switch the log topic accordingly.
    Contact Us

    Contact our sales team or business advisors to help your business.

    Technical Support

    Open a ticket if you're looking for further assistance. Our Ticket is 7x24 avaliable.

    7x24 Phone Support