OSQuery Access API
The OSQuery API requires you to send two different requests in a specific order:
-
Send the OSQuery statement to computers so that the Cytomic EPDR agent prepares the information stored in the database on each computer and sends it to the Cytomic platform. Two API calls are available (
/api/v1/osQuery/client
and/api/v1/osQuery/machine
) depending on whether you want to retrieve information from all computers of one or more clients or from a specific list of computers. As a result, you get an operation ID for each client that reports information from their computers. -
Send each operation ID to get the download URL of the file with information from each client’s computers, or to get the query status.
-
Download a file for each client. This file contains all the information collected from the client’s computers. You can access this resource through the URL obtained in step 2 which, for security reasons, remain actives only for five minutes. After this time, go back to step 2 to get a new download URL
Because there might be computers that are turned off or unavailable, OSQuery statements can be extended indefinitely over time. That is why you must specify a TTL (Time To Live) value, after which Cytomic Orion considers the operation to be completed.
Send a Request to Get Information from One or Multiple Computers
Run an OSQuery-compatible SQL statement on specific computers that belong to the IT infrastructure of one or more clients.
Request
Command |
POST |
URL |
/api/v1/osQuery/machine |
Required parameters in the HTTP message body |
JSON object with the OSQuery query and a list of MUIDs.
|
Headers |
|
Response
List of JSON objects, each with the ID of the operation performed for a client.
JSON object field | Description |
---|---|
pandaID |
Identifier of the client to which the computers that returned data belong. |
operationId |
Identifier of the operation performed. This is necessary to access the URL that contains the OSQuery query results. See Get an OSQuery Query Results. |
MUIDs |
List of identifiers of the client’s computers that returned data |
Send a Request to Get Information from All Computers of One or Multiple Clients
Run an OSQuery-compatible SQL statement on all computers belonging to the IT infrastructure of specific clients.
Request
Command |
POST |
URL |
/api/v1/osQuery/client |
Required parameters in the HTTP message body |
JSON object with the OSQuery query and a list of client IDs.
|
Headers |
|
Response
List of JSON objects, each with information from a client.
JSON object field | Description |
---|---|
pandaID |
Identifier of the client to which the computers that returned data belong. |
operationId |
Identifier of the operation performed. This is necessary to access the URL that contains the OSQuery query results. See Get an OSQuery Query Results. |
MUIDs |
List of identifiers of the client’s computers that returned data |
Get an OSQuery Query Results
Get the URL that points to the file that contains the data collected from the specified computers.
Request
Command |
POST |
URL |
/api/v1/osQuery/state |
Required parameters in the HTTP message body |
List of JSON objects, each with the ID of the operation whose data you want to retrieve.
|
Headers |
|
Response
List of JSON objects, one for each client, with information about the query results.
JSON object field | Description |
---|---|
panda |
Identifier of the client to which the computers that returned data belong. |
operationId |
Identifier of the operation performed. |
url |
Download URL for the file that contains the information collected from computers. This link is valid for five minutes, For more information about the file format, see Download File Format. |
counters |
JSON object with the operation statistics:
|
Monitor Computers Turned Off, Unavailable, or with Delayed Responses
totalOperationElements is equal to the sum of totalSuccess + totalPartiallySucceeded + totalError if all computers respond, either with information or with an error. Because OSQuery statements can take an unspecified time to run, if totalOperationElements is not equal to the sum of totalSuccess + totalPartiallySucceeded + totalError this means there are computers on the client’s network that have not responded yet. In such case, you must send the operationId repeatedly until the totalOperationElements value is the right one or until the timeout established in the ttl field occurs.
Download File Format
The file that contains the data collected from the client’s computers has these features:
-
Name: “osquery_” + operation ID.
-
Format: Text.
-
Header: File fields separated by the “;” character.
-
Body: Lines with the content of the fields extracted by OSQuery from the computer database.
Error Types
Name | Code | Description | Comments |
---|---|---|---|
ErrorExecutingOsQuery |
201 |
near "name": syntax error |
OSQuery is compatible with the 4.2.0 data schema. See OSQuery Requirements and check the OSQuery statement syntax. |
ErrorOsNotSupported |
202 |
Operating system not supported |
OSQuery is compatible with Windows systems. See OSQuery Requirements. |
ErrorOsQueryNotInstalled |
203 |
OSQuery not installed |
OSQuery is available from version 3.71 of Cytomic EDR. See OSQuery Requirements. |
Get an OSQuery Query Status
Get a list of JSON objects with information about the status of in-progress or completed operations.
Request
Command |
POST |
URL |
/api/v1/osQuery/info |
Required parameters in the HTTP message body |
List of JSON objects, each with the ID of the operation whose status you want to retrieve.
|
Optional parameters in the HTTP message body |
|
Headers |
|
Response
List of JSON objects, one for each client, with information about the query results.
JSON object field | Description |
---|---|
panda |
Identifier of the client to which the operation belongs. |
operationId |
Identifier of the operation performed. |
info |
List of JSON objects, one for each client operation, with information about the operation status:
|
Error Types
Name | Code | Description | Comments |
---|---|---|---|
ErrorExecutingOsQuery |
201 |
near "name": syntax error |
OSQuery is compatible with the 4.2.0 data schema. See OSQuery Requirements and check the OSQuery statement syntax. |
ErrorOsNotSupported |
202 |
Operating system not supported |
OSQuery is compatible with Windows systems. See OSQuery Requirements. |
ErrorOsQueryNotInstalled |
203 |
OSQuery not installed |
OSQuery is available from version 3.71 of Cytomic EDR. See OSQuery Requirements. |