All Products
Search
Document Center

Simple Log Service:Add a filter

Last Updated:May 06, 2024

You can add a filter to a dashboard. Then, you can use the filter to refine query results or replace placeholder variables with specific values. This topic describes how to add a filter to a dashboard.

Prerequisites

  • Data is collected. For more information, see Data collection overview.

  • Indexes are configured. For more information, see Create indexes.

  • Charts are added to a dashboard. For more information, see Add a chart to a dashboard.

    Important

    If you set the filter type to Variable Replacement, you must configure placeholder variables for the charts on the dashboard.

Background information

A filter is used to modify query statements or replace placeholder variables for all charts on a dashboard. Each chart displays the query and analysis result of a query statement, which is in the [search query] | [sql query] format. After a filter is added, a new query statement is executed. The following filter types are supported:

  • Filter: uses a key-value pair as a filter condition. The filter condition is added before a query statement by using the AND or NOT operator. For example, Key: Value AND [search query] | [sql query] indicates that the system queries logs that contain Key:Value in the result of the [search query] | [sql query] query statement. For the Filter type, you can select or enter multiple values for one key. If you use multiple key-value pairs, the pairs are evaluated by using a logical OR. For more information, see Add a filter of the Filter type.

  • Variable Replacement: uses a placeholder variable and the value of the placeholder variable. If the dashboard contains a chart for which the same variable is configured, the variable in the query statement of the chart is replaced with the value of the specified variable. This applies to all charts for which the same variable is configured. For more information, see Add a filter of the Variable Replacement type.

  • Metric Filter: dynamically adds labels and values to filter data. You can add multiple filter conditions, and the filter conditions are evaluated by using a logical AND.

Procedure

  1. Log on to the Simple Log Service console.

  2. Go to the Dashboard page.

    1. In the Projects section, click the project that you want to manage.

    2. In the left-side navigation pane, choose Dashboard > Dashboards.

    3. In the Dashboard list, click the required dashboard.

  3. In the upper-right corner of the page that appears, click Edit.

  4. In the top toolbar, click the 过滤 icon.

  5. In the Filter panel, configure the parameters and click OK. The following table describes the parameters.

    Parameter

    Description

    Name

    The name of the filter.

    Display Configuration

    The pattern settings of the filter. The following pattern settings are available:

    • Display Title: adds a title to the filter.

    • Display Border: adds borders to the filter.

    • Display Background: adds a white background to the filter.

    Type

    The type of the filter.

    • Filter: Add key-value pairs to filter data. Key-value pairs are added before a query statement by using the AND or NOT operator. By default, the AND operator is used.

      • AND: Value AND [search query] | [sql query]

      • NOT: Value NOT [search query] | [sql query]

      You can specify multiple values in the Static List Items field.

    • Variable Replacement: Specify a variable and the value of the variable. If the dashboard contains a chart for which the same variable is configured, the variable in the query statement of the chart is replaced with the value of the specified variable. You can specify multiple values for the variables in the Static List Items field.

    • Metric Filter: The system dynamically adds labels and values to filter data. After a filter of this type is added, you can filter data of a Metricstore by using labels and values.

    Key Value

    • If you select Filter, enter the field that you want to use to filter data in the Key Value field.

    • If you select Variable Replacement, enter the variable that you want to use to filter data in the Key Value field.

    • If you select Metric Filter, enter the unique identifier of the filter in the Key Value field.

      Note

      If you select Variable Replacement, you must configure a placeholder variable for charts. The placeholder variable must be the same as the variable that you specify in the Key Value field.

    Alias

    The alias of the column. This parameter is required only if you select Filter.

    Global Filtering

    This parameter is required only if you select Filter.

    • If you want to filter values in all fields, turn on Global Filtering.

    • If you want to filter values in specific fields, turn off Global Filtering.

    Automatic Filtering

    If you turn on Automatic Filtering, values that do not exist in the data source are automatically filtered out. This parameter is required only if you select Filter.

    Query Method

    The operator that you want to use to add key-value pairs before a query statement. Valid values: AND Operator and NOT Operator. This parameter is required only if you select Filter.

    Show Component Types

    This parameter is required only if you select Variable Replacement.

    You can configure this parameter to specify a component type. The following methods are supported:

    • Enter a value

    • Drop-down List

    Select Project

    The project that you want to query. This parameter is required only if you select Metric Filter.

    Select Metricstore

    The Metricstore that you want to query. This parameter is required only if you select Metric Filter.

    Static List Items

    The value of the variable. You must specify the value based on the Key Value field.

    You can click the plus sign (+) to add more values for the specified key. If you turn on Select by Default for a value, the value is used to filter data each time you open a dashboard.

    Add Dynamic List Item

    If you turn on Add Dynamic List Item, dynamic values can be retrieved for the keys specified in the Key Value field. Dynamic list items are dynamic query results that are obtained by executing the specified query statement. The query results vary based on the time ranges.

    If you turn on Add Dynamic List Item, you must configure the following parameters:

    • Select Project: Select the project that you want to query.

    • Select Logstore: Select the Logstore that you want to query.

    • Inherit Filter Condition: If you turn on Inherit Filter Condition, the filter condition on the dashboard is added before the query statement.

    • Query statement: Enter a query statement and specify a time range.

    • Dynamic List Item Preview: Preview query results.