nomad icon indicating copy to clipboard operation
nomad copied to clipboard

Search for AllocationId in Web UI

Open sevensolutions opened this issue 3 months ago • 2 comments

Proposal

It would be great if i can search the corresponding job from a given allocation id in the Web UI.

Use-cases

Sometimes you have an allocation id, maybe from a logging solution etc. and you want to find the corresponding job.

Attempted Solutions

Maybe we can add a button to the topology view which shows a small dialog to enter an alloc id and then highlight or pre-select the corresponding allocation. I've already seen in the DOM that the allocation id is already there so shouldn't be too hard to implement. I can try to work on this and create a draft PR.

Allowing someone to just paste in the alloc id in the top "Jump to" search bar would also be a gread feature, but i think this is much harder to implement.

sevensolutions avatar Nov 19 '25 16:11 sevensolutions

Hi @sevensolutions! I thought we already did support this but you're right that the search box doesn't allow for it now. The API supports getting allocations by ID for the Prefix Search API but not the Fuzzy Search API used by the UI's search box. For example...

Prefix search:

$ echo '{"Context": "all", "Prefix": "9706d61a"}' | nomad operator api -verbose -X POST "/v1/search"
* Reading request body from stdin.
> POST /v1/search HTTP/1.1
>
* Sending request and receiving response...
< HTTP/1.1 200 OK
< X-Nomad-Knownleader: true
< X-Nomad-Lastcontact: 0
< Date: Wed, 19 Nov 2025 17:15:28 GMT
< Content-Type: application/json
< Vary: Accept-Encoding
< X-Nomad-Index: 19
{"Index":19,"KnownLeader":true,"LastContact":0,"Matches":{"jobs":null,"evals":null,"plugins":null,"deployment":null,"volumes":null,"vars":null,"nodes":null,"node_pools":null,"scaling_policy":null,"namespaces":null,"host_volumes":null,"allocs":["9706d61a-b05c-5361-c297-5e5abe724e66"]},"NextToken":"","Truncations":{"evals":false,"volumes":false,"plugins":false,"host_volumes":false,"jobs":false,"deployment":false,"vars":false,"nodes":false,"node_pools":false,"scaling_policy":false,"namespaces":false,"allocs":false}}%

Fuzzy search:

$ echo '{"Context": "all", "Text": "9706d61a"}' | nomad operator api -verbose -X POST "/v1/search/fuzzy"
* Reading request body from stdin.
> POST /v1/search/fuzzy HTTP/1.1
>
* Sending request and receiving response...
< HTTP/1.1 200 OK
< X-Nomad-Knownleader: true
< X-Nomad-Lastcontact: 0
< Date: Wed, 19 Nov 2025 17:15:04 GMT
< Content-Type: application/json
< Vary: Accept-Encoding
< X-Nomad-Index: 19
{"Index":19,"KnownLeader":true,"LastContact":0,"Matches":{"host_volumes":[],"evals":[],"deployment":[],"volumes":[],"scaling_policy":[]},"NextToken":"","Truncations":{"jobs":false,"node_pools":false,"namespaces":false,"deployment":false,"scaling_policy":false,"host_volumes":false,"nodes":false,"plugins":false,"vars":false,"evals":false,"volumes":false,"allocs":false}}%

This seems like a good idea to support, although whether we want to support it by making the fuzzy search API fallback to prefix search or whether we want the UI to do so is up for grabs. I'll mark this for roadmapping.

tgross avatar Nov 19 '25 17:11 tgross

Oof, looks like we've had https://github.com/hashicorp/nomad/issues/10589 open for a while with this same request. I'll close that out in lieu of this one.

tgross avatar Nov 19 '25 17:11 tgross