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

Prerequisites

  • Log data is collected. For more information, see Log collection methods.
  • Indexes are created for log data. For more information, see Configure indexes.
  • Charts are added to a dashboard. For more information, see Add charts to a dashboard.
    Notice If the filter type is set to Replace Variable, you must configure placeholder variables for the charts on the dashboard.

Background information

A filter modifies the query statements or replaces placeholder variables for all charts on a dashboard. Each chart displays the query and analysis results 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 list describes available filter types:
  • 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. If the AND operator is used, the new query statement is in the Key: Value AND [search query] | [sql query] format. This statement searches the query results of the original query statement for log entries that contain Key:Value. For the Filter type, you can select or enter multiple key-value pairs. If you use multiple key-value pairs, the logical OR operator is used between the pairs. For more information about how to add a filter of the Filter type, see Add a filter of the Filter type.
  • Replace Variable: 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 specified variable value that you select. This applies to all charts for which the same variable is configured. For more information about how to add a filter of the Replace Variable type, see Add a filter of the Replace Variable type.

Procedure

  1. Log on to the Log Service console.
  2. In the Projects section, click the project in which you want to query and analyze logs.
  3. In the left navigation sidebar, click the Dashboard icon icon.
  4. In the Dashboard pane, click the dashboard that you want to manage.
  5. In the upper-right corner of the page that appears, click Edit.
  6. Click the Filter icon icon.
  7. In the Filter panel, configure the following parameters and click OK.
    Parameter Description
    Filter Name The name of the filter.
    Display Settings Valid values:
    • Title: specifies whether to add a title for the filter. You can turn on Title to add a title for the filter.
    • Border: specifies whether to add borders to the filter. You can turn on Border to add borders to the filter.
    • Background: specifies whether to add a white background to the filter. You can turn on Background to add a white background to the filter.
    Type The type of the filter.
    • Filter: filters data by using key-value pairs. The key-value pairs are added before a query statement by using the AND or NOT operator. By default, AND is used.
      • AND: Value AND [search query] | [sql query]
      • NOT: Value NOT [search query] | [sql query]

      You can specify multiple values of key-value pairs in the Static List Items field.

    • Replace Variable: specifies a variable and the variable value. 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 specified variable value that you select. You can set multiple values of key-value pairs in the Static List Items field.
    Key
    • If you select Filter, enter the key that you use to filter data in the Key field.
    • If you select Replace Variable, enter the variable that you use to filter data in the Key field.
      Note If you select Replace Variable, you must configure a placeholder variable. The placeholder variable must be the same as the variable that you specify in the Key field.
    Alias The alias of the filter. This parameter is available only when you select Filter.
    Global filter The parameter is available only when you select Filter.
    • To search for the specified value in all fields, turn on Global filter.
    • To search for the specified value in the specified key, turn off Global filter.
    Static List Items The value for Key that is used to filter data.

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

    Add Dynamic List Item If you turn on Add Dynamic List Item, dynamic values can be retrieved for Key. Dynamic list items are dynamic values that are retrieved by executing the specified query statement. The values vary based on the time ranges during which the query statement is executed.
    If you turn on Add Dynamic List Item, you must configure the following parameters:
    • Select Logstore: Select a Logstore from which data is queried.
    • Inherit Filtering: If you turn on Inherit Filtering, 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.