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.
- Log data is collected. For more information, see Data collection overview.
- Indexes are configured. For more information, see Configure indexes.
- Charts are added to a dashboard. For more information, see Add charts to a dashboard.
Notice If you set the filter type to Replace Variable, you must configure placeholder variables for the charts on the dashboard.
- 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, the Key: Value AND [search query] | [sql query] statement queries logs that contain Key:Value in the query result of the [search query] | [sql query] statement. 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 value of the specified variable. 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.
- Log on to the Log Service console.
- Access the Dashboard page.
- In the Projects section, click the name of the project that you want to view.
- In the left-side navigation pane, click Dashboard.
- In the Dashboard list, click the required dashboard.
- In the upper-right corner of the page that appears, click Edit.
- In the top toolbar, click the icon.
- In the Filter panel, configure the following parameters and click OK.
Parameter Description Filter Name The name of the filter. Display Settings The pattern settings of the filter. The following pattern settings are available:
- Title: adds a title for the filter.
- Border: adds borders to the filter.
- Background: adds a white background to the filter.
Type The type of the filter.
- Filter: filters data by using key-value pairs. 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.
- Replace Variable: specifies 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.
- If you select Filter, enter the field that you want to use to filter data in the Key field.
- If you select Replace Variable, enter the variable that you want to use to filter data in the Key field.
Note If you select Replace Variable, you must specify a placeholder variable when you add a chart to the dashboard. The placeholder variable must be the same as the variable that you specify in the Key field.
Alias The alias of the column. This parameter is available only when you select Filter. Global filter The parameter is available only when you select Filter.
- If you want to filter the specified values in all fields, turn on Global filter.
- If you want to filter the specified values in specific fields, turn off Global filter.
Static List Items The value of the Key field 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, 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 Key field. 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 Conditions: If you turn on Inherit Filtering Conditions, 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.