How do we get live query results via web apis ?
# kolide
s
How do we get live query results via web apis ?
s
The
fleetctl
tool implements an example of how to do this. https://github.com/kolide/fleet/blob/master/cmd/fleetctl/query.go
s
thanks. Any idea if i can get these working without using the cli ?
c
@Saif Abulkhair the Kolide platform is built with Go Kit so most actions performed via the webgui is an API call. The Kolide “API” has not been officially documented but reading the HTTP handlers file will be helpful. I don’t have access to my homelab Kolide instance because I am at work but here are some starter curl statements and API endpoints First, you need to authenticate yourself:
curl -X POST https://<Kolide>/api/v1/kolide/login -d '{"Username": "<Kolide admin e-mail>", "Password": "<Kolide admin password>"}'
When you successfully login you should receive a JWT token which you will use for all future API requests to Kolide. Here is the Kolide login code. Next, you can use the JWT to perform API operations such as getting a list of queries: /api/v1/kolide/queries. Next, request query results using /api/v1/kolide/results/
🙌 1
1
s
Awesome. I wll try thhese pointers and hopefully would come back to thank you again.😁
@CptOfEvilMinions this is what i tried and reached.
1 Login using /login endpoint 2. Get the lsit of all queires using / queries endpoint 3. Execute one of the query using /queries/run endpoint and passing the body something like this
{"query":"SELECT name[Software Name], bundle_short_version[Software version], bundle_identifier[Software publisher] FROM apps \nwhere bundle_identifier not like '%com.apple%' and \npath like ( '%/Applications/' ||apps.name);","selected":{"hosts":[],"labels":[7]}}
I can see from code that a websocket gets created and its the websocket which returns the queries results. How do i consume the websocket which is generted at runitme ?
s
See the
fleetctl
source I linked previously, it shows an example of how to do so in Golang