Hey Fleet team, I'm a bit confused about concept of label query and policy query. Do we have more official doc talk about them? I can only find few words for policy query. https://fleetdm.com/docs/rest-api/rest-api#policies
What are their difference? In which scenario, we should define a label query or a policy query?
Thanks!
g
Grant Bilstad
10/10/2023, 2:02 PM
Greetings Jason!
Label Queries are used for organizing your hosts into groups or filtering based on the criteria. https://fleetdm.com/docs/configuration/configuration-files#labels
Policy Queries should return "0" or "1"
Meaning, is this host passing the policy? (this can get a bit confusing based on how wanting to display "No" or "Yes") Policy queries usually start with a
SELECT 1 FROM
You can also run Policy Queries on Labels
j
Jian Zheng
10/10/2023, 4:52 PM
Thanks for your response!
If I understand correct, we also treat label queries' results as "0" or "1". (Either in the group or not).
So the queries have no difference?
The difference between label and policy it that we use label to filter hosts. For policy, we try to run a policy query to get a result. Am I understanding this correct?
g
Grant Bilstad
10/10/2023, 6:03 PM
Correct! if returns something other than "0"
Labels - Organize hosts for filtering/running live queries
Policies - Check the compliance of the host