* Website: add 6 product articles & images, update styles * Update articles/fleet-quick-tips-querying-procdump-eula-has-been-accepted.md Co-authored-by: Mike Thomas <78363703+mike-j-thomas@users.noreply.github.com>
3.9 KiB
Import and export queries and packs in Fleet
When managing multiple Fleet environments, you may want to move queries and/or packs from one environment to the other. Or, when inspired by a set of packs shared by a member of the osquery community, you might want to import these packs into your Fleet instance. To do this, you need to have access to a Unix shell and a basic knowledge of the fleetctl CLI tool.
Below are two example scenarios. For leaner instructions on how to move queries and packs from one Fleet environment to another, check out Fleet’s documentation.
Example scenario 1: Moving packs, and their queries, from one Fleet environment to another
Let’s say you manage your organization’s staging and production servers. In order to keep your production servers speedy, you’ve set up two separate Fleet instances for the two environments: Staging and Production.
With this separation, you can diligently test your queries in Staging without negatively impacting the performance of servers in Production.
On Friday, after test results come in, you want to move all performant packs, and their queries, from Staging to Production. You know you can open up the Fleet UI for Production and create the packs manually, but each pack has at least 4 new queries. These packs already exist in Staging so you don’t need to spend time recreating each one in Production.
Here’s how you can quickly export and import the packs in 3 quick fleetctl commands:
-
Navigate to
~/.fleet/config
to find the context names for your “exporter” and “importer” environment. For the purpose of these instructions, we use the context namesstaging
andproduction
respectively. -
Run the command
fleetctl get queries --yaml --context staging > queries.yml && fleetctl apply -f queries.yml --context production
. This will import all the queries from your Staging Fleet instance into your Production Fleet instance. Note, this will also write a list of all queries in yaml syntax to a file namesqueries.yml
. -
Run the command
fleetctl get packs --yaml --context staging > packs.yml && fleetctl apply -f packs.yml --context production
. This will import all the packs from your Staging Fleet instance into your Production Fleet instance. Note, this will also write a list of all packs in yaml syntax to a file namespacks.yml
.
Note, when importing packs, you must always first import all the queries (step 2) that these packs contain.
Example scenario 2: Importing community packs into Fleet
You just found a collection of awesome queries and packs for Fleet and you want to import them into your Staging Fleet environment.
Here’s how you can do this in 2 quick fleetctl commands.
- Create a new file,
awesome-packs.yml
and paste in the desired packs and queries in the correct Fleet configuration format. - Run the command
fleetctl apply -f awesome-packs.yml
.
Could this post be more helpful?
Let us know if you can think of any other example scenarios you’d like us to cover.