Noah Talerman
Noah Talerman
Queries in Fleet allow you to ask questions to help you manage, monitor, and identify threats on your devices. This guide will walk you through how to create, schedule, and run a query.
Note: Unless a logging infrastructure is configured on your Fleet server, osquery-related logs will be stored locally on each device. Read more here
New users may find it helpful to start with Fleet's policies. You can find policies and queries from the community in Fleet's query library. To learn more about policies, see What are Fleet policies? and Understanding the intricacies of Fleet policies.
How to create a query:
In the top navigation, select Queries.
Select Create new query to navigate to the query console.
In the Query field, enter your query. Remember, you can find common queries in Fleet's library.
Avoid using dot notation (".") for column names in your queries as it can cause results to render incorrectly in Fleet UI. Please see issue #15446 for more details.
Select Save, enter a name and description for your query, select the frequency that the query should run at, and select Save query.
How to view a query report:
In the top navigation, select Queries.
In the Queries table, find the query you'd like to run and select the query's name to navigate to the query console.
If you want to download the query report, select Export results to save it as a CSV.
Fleet will store up to 1000 results for each scheduled query to give users a snapshot of query results. If the number of results for a scheduled query is below 1000, then the results will continuously get updated every time the hosts send results to Fleet.
You can tell Fleet to store more than 1000 results in query reports by setting
server_settings.query_report_cap
via the Modify configuration API endpoint.
Persisting query reports within Fleet creates load on the database, so you'll want to monitor database load as you add queries. If needed, you can disable query reports either globally or per-query.
server_settings.query_reports_disabled
via the Modify configuration endpointdiscard_data
field when creating or modifying the queryRun a live query to get answers for all of your online hosts.
Offline hosts won’t respond to a live query because they may be shut down, asleep, or not connected to the internet.
How to run a query:
In the top navigation, select Queries.
In the Queries table, find the query you'd like to run and select the query's name to navigate to the query console.
Select Live query to navigate to the target picker. Select All hosts and select Run. This will run the query against all your hosts.
If you want to download the live query results, select Export results to save it as a CSV.
Fleet 4.24.0 and later versions provide notifications in the activity feed for live queries.
The query may take several seconds to complete because Fleet has to wait for the hosts to respond with results.
Fleet's query response time is inherently variable because of osquery's heartbeat response time. This helps prevent performance issues on hosts.
Fleet allows you to schedule queries to run at a set frequency. By default, queries that run on a schedule will only target platforms compatible with that query. This behavior can be overridden by setting the platforms in Advanced options when saving a query.
Scheduled queries will send data to Fleet and/or your log destination automatically. Query automations can be turned off in Advanced options or using the bulk query automations UI.
How to configure query automations in bulk:
Only users with the admin role can manage query automations.
In the top navigation, select Queries.
Select Manage automations.
Check the box next to the queries you want to send data to your log destination, and select Save. (The frequency that queries run at is set when a query is created.)
Note: When viewing a specific team in Fleet Premium, only queries that belong to the selected team will be listed. When configuring query automations for all hosts, only global queries will be listed.