API Stability |
Sjprt-Term
|
The searchFleet() GraphQL query is used to query the list of fleet-configured hosts.
Syntax
Below is the syntax for the searchFleet() query field:
searchFleet(
changeFilter: Changes,
configurationFilter: ConfigurationFilter,
queryState: string,
inactiveFilter: boolean,
statusFilter: SearchFleetStatusFilter,
testConfigIdFilter: string,
configIdFilter: string,
searchFilter: string,
sortBy: Fleet__SortBy = Hostname,
orderBy: OrderBy,
skip: integer,
limit: integer
): SearchFleetUnion!
Given Datatypes
Several of the given datatypes are standard types (e.g., string, integer). However, there are a few with special datatypes.
The data type, Changes is enumerated with
three possible values: Removed
,
Added
or NoChange
.
The data type, SearchFleetStatusFilter
filters the output based on whether the host is in the
Error
or OK
state.
For the given input type,
ConfigurationFilter(), there are a couple of
parameters, each accepting a string:
oldQuery
(value not required); and
newQuery
For sorting, you can se the values enumerated for
Fleet__SortBy
below:
Table: Fleet__SortBy
Parameter | Type | Required | Default | Stability | Description |
---|---|---|---|---|---|
Some arguments may be required, as indicated in the Required column. For some fields, this column indicates that a result will always be returned for this column. | |||||
Table last updated: Sep 13, 2024 | |||||
Change | boolean | Short-Term | Whether to sort by change. | ||
ConfigName | boolean | Short-Term | Whether to sort by the configuration name. | ||
CpuAverage5Min | boolean | Short-Term | Whether to sort by CPU five-minute average. | ||
DiskMax5Min | boolean | Short-Term | Whether to sort by the disk usage five-minute maximum. | ||
Hostname | boolean | Short-Term | Whether to sort by the host name. | ||
Ingest | boolean | Short-Term | Whether to sort by ingest source. | ||
LastActivity | boolean | Short-Term | Whether to sort by activity, the last first. | ||
MemoryMax5Min | boolean | Short-Term | Whether to sort by memory five-minute maximum. | ||
System | boolean | Short-Term | Whether to sort by system. | ||
Version | boolean | Short-Term | Whether to sort by version. |
Returned Datatypes
The returned datatype SearchFleetUnion() is a
union: SearchFleetUnion = SearchFleetResultSet |
SearchFleetInProgress
.
searchFleet() Examples
The main call to searchFleet() specifies the basic search filter, sort, order and length of the result set.
Results start at zero:
searchFleet: searchFleet(
searchFilter: ""
sortBy: Hostname
orderBy: ASC
skip: 0
limit: 10
)
To paginate over multiple results, set the
skip to the first
result. For example, if the
limit argument is
10
, then the next set of results is available by
setting skip to
11
.
To get more specific information, use a query that filters and lists the fields that you want o view.
Listing Active Configurations
To obtain a list of active configurations in use by hosts, filter the returned results with the configurations blocks.
query {
searchFleet: searchFleet(
searchFilter: ""
sortBy: Hostname
orderBy: ASC
skip: 0
limit: 10
) {
__typename
...on SearchFleetResultSet {
results {
configurations {
assignment: assignment
name: name
id: id
}
}
}
}
}
{
"data": {
"searchFleet": {
"__typename": "SearchFleetResultSet",
"results": [
{
"configurations": [
{
"assignment": "Manual",
"name": "base2",
"id": "K9nrIRwxrmSNwBdvIfQkDh0Vfw0lDpFJ"
}
]
}
]
}
}
}
Note that this only outputs the list of configurations in use, not all of the available configurations.
Listing Log Sources Across Hosts
To obtain a list of the log sources and parsers used across all hosts, filter the returned results with the logSources block:
{
searchFleet: searchFleet(
searchFilter: ""
sortBy: Hostname
orderBy: ASC
skip: 0
limit: 10
) {
__typename
... on SearchFleetResultSet {
results {
configName: configName
logSources {
parser: parser
repository: repository
sourceType: sourceType
sourceName: sourceName
}
}
}
}
}
{
"data": {
"searchFleet": {
"__typename": "SearchFleetResultSet",
"results": [
{
"configName": "base2",
"logSources": [
{
"parser": "syslog",
"repository": "systemlogs",
"sourceType": "file",
"sourceName": "var_log"
}
]
}
]
}
}
}
Finding Hosts in Error State
To get a list of the hosts that are in an OK state, add the
statusFilter
argument with a value of
OK
.
{
searchFleet: searchFleet(
searchFilter: ""
sortBy: Hostname
orderBy: ASC
skip: 0
limit: 10
statusFilter: OK
) {
__typename
... on SearchFleetResultSet {
results {
configName: configName
hostname
machineId
ipAddress
}
}
}
}
{
"data": {
"searchFleet": {
"__typename": "SearchFleetResultSet",
"results": [
{
}
]
}
}
}
For hosts in the error state, use
Error
.
{
searchFleet: searchFleet(
searchFilter: ""
sortBy: Hostname
orderBy: ASC
skip: 0
limit: 10
statusFilter: OK
) {
__typename
... on SearchFleetResultSet {
results {
configName: configName
hostname
machineId
ipAddress
}
}
}
}
{
"data": {
"searchFleet": {
"__typename": "SearchFleetResultSet",
"results": [
{
"configName": "base2",
"hostname": "ReacherGilt",
"machineId": "a0e76cc5-a974-4f6b-8ef0-a164d521d71c",
"ipAddress": "fe80:0:0:0:468:a3fe:6479:8ba2"
}
]
}
}
}
Getting Full Fleet Host Details
query {
searchFleet: searchFleet(
searchFilter: ""
sortBy: Hostname
orderBy: ASC
skip: 0
limit: 10
) {
__typename
...on SearchFleetResultSet {
results {
change: change
configurations {
assignment: assignment
name: name
id: id
}
diskMax5Min: diskMax5Min
memoryMax5Min: memoryMax5Min
cpuAverage5Min: cpuAverage5Min
cfgTestId: cfgTestId
errors: errors
configId: configId
configName: configName
logSources {
parser: parser
repository: repository
sourceType: sourceType
sourceName: sourceName
}
ipAddress: ipAddress
lastActivity: lastActivity
ingestLast24H: ingestLast24H
version: version
system: system
hostname: hostname
machineId: machineId
id: id
}
totalResults: totalResults
}
...on SearchFleetInProgress {
queryState: queryState
}
}
}
{
"data": {
"searchFleet": {
"__typename": "SearchFleetResultSet",
"results": [
{
"configName": "base2",
"lastActivity": "2024-03-01T04:31:09Z",
"errors": [],
"version": "1.6.2",
"ipAddress": "fe80:0:0:0:468:a3fe:6479:8ba2",
"configurations": [
{
"assignment": "Manual",
"name": "base2",
"id": "K9nrIRwxrmSNwBdvIfQkDh0Vfw0lDpFJ"
}
],
"cpuAverage5Min": 0.10625,
"hostname": "ReacherGilt",
"system": "macOS 14.3.1 (arm64)",
"logSources": [
{
"parser": "syslog",
"repository": "systemlogs",
"sourceType": "file",
"sourceName": "var_log"
}
],
"machineId": "a0e76cc5-a974-4f6b-8ef0-a164d521d71c",
"change": null,
"id": "J7v8VPxQpsisowLiL68F83NvAaBF3wiW",
"ingestLast24H": 2076167,
"configId": "K9nrIRwxrmSNwBdvIfQkDh0Vfw0lDpFJ",
"memoryMax5Min": 541310976,
"diskMax5Min": 53.68,
"cfgTestId": null
}
],
"totalResults": 1
}
}
}