Search HTTP API
Prefix Searching
The /search
endpoint returns matches for a given prefix and context, where a
context can be jobs, allocations, evaluations, nodes, deployments, plugins,
namespaces, or volumes. When using Nomad Enterprise, the allowed contexts
include quotas. Additionally, a prefix can be searched for within every
context.
Method | Path | Produces |
---|---|---|
POST | /v1/search | application/json |
The table below shows this endpoint's support for blocking queries and required ACLs.
Blocking Queries | ACL Required |
---|---|
NO | see below |
When ACLs are enabled, requests must have a token that grants access to "list"
or "read" capabilities for the objects in the search context. For example,
node:read
, node_pool:read
, plugin:read
, or namespace:read-jobs
roles. If
the token is only valid for a portion of these capabilities, then results will
include results including only data readable with the given token.
Parameters
Prefix
(string: <required>)
- Specifies the identifier against which matches will be found. For example, if the given prefix were "a", potential matches might be "abcd", or "aabb".Context
(string: <required>)
- Defines the scope in which a search for a prefix operates. Contexts can be: "jobs", "evals", "allocs", "nodes", "deployment", "plugins", "volumes" or "all", where "all" means every context will be searched.
Sample Payload (for all contexts)
Sample Request
Sample Response
Field Reference
Matches
- A map of contexts to matching arrays of identifiers.Truncations
- Search results are capped at 20; if more matches were found for a particular context, it will betrue
.
Sample Payload (for a specific context)
Sample Request
Sample Response
Fuzzy Searching
The /search/fuzzy
endpoint returns partial substring matches for a given search
term and context, where a context can be jobs, allocations, nodes, plugins, or namespaces.
Additionally, fuzzy searching can be done across all contexts. For better control
over the performance implications of fuzzy searching on Nomad servers, aspects of
fuzzy searching can be tuned through the search
block in Nomad agent config.
Fuzzy search results are ordered starting with closest matching terms. Items of a name that exactly matches the search term are listed first.
Method | Path | Produces |
---|---|---|
POST | /v1/search/fuzzy | application/json |
The table below shows this endpoint's support for blocking queries and required ACLs.
Blocking Queries | ACL Required |
---|---|
NO | see below |
When ACLs are enabled, requests must have a token that grants access to "list"
or "read" capabilities for the objects in the search context. For example,
node:read
, node_pool:read
, plugin:read
, or namespace:read-jobs
roles. If
the token is only valid for a portion of these capabilities, then results will
include results including only data readable with the given token.
Parameters
Text
(string: <required>)
- Specifies the identifier against which matches will be found. For example, if the given text were "py", potential fuzzy matches might be "python", "spying", or "happy".Context
(string: <required>)
- Defines the scope in which a search for a prefix operates. Contexts can be: "jobs", "allocs", "nodes", "plugins", or "all", where "all" means every context will be searched. When "all" is selected, additional prefix matches will be included for the "deployments", "evals", and "volumes" types. When searching in the "jobs" context, results that fuzzy match "groups", "services", "tasks", "images", "commands", and "classes" are also included in the results.
Scope
Fuzzy match results are accompanied with a Scope
field which is used to uniquely
identify the matched object, in a way that the Nomad API can be queried again for
additional information. The data provided by scope varies depending on the type
of matched object, described below.
Sample Payload (for jobs)
Sample Request
Sample Response
Scope (jobs)
Scope (groups)
Scope (tasks)
Scope (group services)
Scope (task services)
Scope (commands/images/classes)
Sample Payload (for nodes)
Sample Request
Sample Response
Scope (nodes)
Scope[0]
: Node ID
Sample Payload (for allocs)
Sample Request
Sample Response
Scope (allocs)
Sample Payload (for plugins)
Sample Request
Sample Response
Sample Payload (for all)
Sample Request
Prefix matching when fuzzy searching
If the search Context is all
when fuzzy searching, the object types that are
identified only with UUIDs are also concurrently prefix-searched. Those types include
deployments, evals, volumes, and quotas (Enterprise).
Sample Payload (prefix match)
Sample Request
Sample Result