https://github.com/osquery/osquery logo
#fleet
Title
# fleet
a

Adam Connor

01/16/2023, 7:24 AM
ok I guess the answer is that the tables aren’t directly exposed via API and I can’t query them directly. In that case, how can I pull a list of all my hosts and their labels please?
k

Kathy Satterlee

01/16/2023, 4:30 PM
Hey Adam! Correct, those are Fleet database tables. You can filter hosts by label in the UI or use the `labels`API endpoint. https://fleetdm.com/docs/using-fleet/rest-api#labels
a

Adam Connor

01/23/2023, 12:55 AM
thanks @Kathy Satterlee, I’ve looked over the docs again, and I still can’t see the solution. My goal is to get a list of all hosts and their labels using the API. From the docs it looks like my only solutions are • get a list of all the labels via API and do multiple queries iterating through those labels, then deleting double ups that overlap due to having multiple labels • modifying the default ‘hosts’ query to make it add the labels to the response Am I missing anything here? Is there an easier solution?
ok, there is actually a label called ‘All hosts’ but it does not bring in the labels for each host. So it looks like I could either modify the default hosts query, or modify the label ‘all hosts’ query to get that data