This page explains how to create dashboards with filters that let you choose the data you want to display.
Filters let you choose the data you want to display in your dashboard. This page explains how to create and configure dashboards with filters.
Try out all the examples explained on this page in the HTTP logs dashboard of the Axiom Playground.
You can use two types of filter in your dashboards:
To see different filters in action, check out the HTTP logs dashboard of the Axiom Playground. The search filter on the top right lets you search for a specific phrase in the user agent field to only display HTTP requests from a specific user agent. The select filters on the top left let you choose country and city to only display HTTP requests from a specific geographical origin.
In each chart on your dashboard, you can use all, some, or none of the filters to narrow down the data displayed in the chart. For example, in the HTTP logs dashboard of the Axiom Playground, the charts Popular data centers and Popular countries aren’t affected by your choices in the select filters. You choose to use a filter in a chart by referencing the unique ID of the filter in the chart query as explained later on this page.
Filters can be interdependent. For example, in the HTTP logs dashboard of the Axiom Playground, the values you can choose in the city filter depend on your choice in the country filter. You make a filter dependent on another by referencing the unique ID of the filter as explained later on this page.
For each filter, you define a unique ID when you create the filter. When you create multiple filters, all of them must have a different ID. You can later use this ID to reference the filter in dashboard charts and other filters.
Filters are visually displayed in your dashboard in a filter bar that you can create and move as any other chart. You can add different types of filter to a single filter bar. A filter bar can contain maximum one search filter and any number of select filters.
user_agent_filter
.Try out this filter in the HTTP logs dashboard of the Axiom Playground.
country_filter
.France
is displayed in the list of options, and the value FR
is used to filter data in your charts. Define the key-value pairs in one of the following ways:
project
command to create key-value fields from any output.The value in the key-value pairs must be a string. To use number or Boolean fields, convert their values to strings using tostring()
.
The example APL query below uses the distinct values in the geo.country
field to populate the list of options. It projects these values as both the key and the value and sorts them in alphabetical order.
See this filter in action in the HTTP logs dashboard of the Axiom Playground.
Sometimes it makes sense that filters depend on each other. For example, in one filter you select the country, and in the other filter the city. In this case, the list of options in the city filter depends on your choice in the country filter.
To create a filter that depends on another filter, follow these steps:
country_filter
.city_filter
. The dependent filter must be a select filter.declare query_parameters
at the beginning of your query to reference the independent filter’s ID. For example, declare query_parameters (country_filter:string = "")
. This lets you use country_filter
as a parameter in your query even though it doesn’t exist in your data. For more information, see Declare query parameters.country_filter
parameter to filter results in the dependent filter’s query.The example APL query below defines the dependent filter. It uses the value of the independent filter with the ID country_filter
to determine the list of options in the dependent filter. Based on the selected country, the APL query uses the distinct values in the geo.city
field to populate the list of options. It projects these values as both the key and the value and sorts them in alphabetical order.
Check out this filter in the HTTP logs dashboard of the Axiom Playground.
After creating a filter, specify how you want to use the value chosen in the filter. Include the filter in the APL query of each chart where you want to use the filter to narrow down results. To do so,
use declare query_parameters
at the beginning of the chart’s APL query to reference the filter’s ID. For example, declare query_parameters (country_filter:string = "")
. This lets you use country_filter
as a parameter in the chart’s query even though it doesn’t exist in your data. For more information, see Declare query parameters.
The APL query below defines a statistic chart where the data displayed depends on your choice in the filter with the ID country_filter
. For example, if you choose France in the filter, the chart only displays the number of HTTP requests from this geographical origin.
You can combine several filters of different types in a chart’s query. For example, the APL query below defines a statistic chart where the data displayed depends on three filters:
user_agent
field.See this filter in action in the Total requests chart in the HTTP logs dashboard of the Axiom Playground.
Use declare query_parameters
at the beginning of an APL query to reference a filter’s ID. For example, declare query_parameters (country_filter:string = "")
. This lets you use country_filter
as a parameter in the chart’s query even though it doesn’t exist in your data.
The declare query_parameters
statement defines the data type of the parameter. In the case of filters, the data type is always string.
The default option of a select filter is the option chosen when the dashboard loads. In most cases, this means that no filter is applied. This option is added automatically as the first in the list of options when you create the filter with the key All and an empty value. To choose another default value, reorder the list of options.
The examples on this page assume that you use the default setting where the All key means an empty value, and the empty value in a filter means that the data isn’t filtered in the chart. The example chart queries above handle this empty (null) value in the where
clause. For example, where isempty(country_filter) or ['geo.country'] == country_filter
means that if no option is chosen in the country filter, isempty(country_filter)
is true and the data isn’t filtered. If any other option is chosen with a non-null value, the chart only displays data where the geo.country
field’s value is the same as the value chosen in the filter.