hashicorp / hashicorp/nomad

Client API: Prometheus HTTP SD endpoint for local allocations

Open
#28,115 3 comments 0 reactions 0 assignees View on GitHub
hcc/jira stage/needs-discussion stage/waiting-reply theme/api theme/metrics type/enhancement
Dominant language
Go
Stars
17k
Forks
2.1k
Avg merge
1d 9h
Merged PRs (30d)
105

Description

### Proposal

Add `GET /v1/client/allocations/prometheus-sd` to the client agent HTTP API, serving the node's running allocations as [Prometheus HTTP SD](https://prometheus.io/docs/prometheus/latest/http_sd/) target groups.

One target group per allocated port of every running allocation, labeled with `__meta_nomad_*` labels (namespace, job, task group, allocation, node, port) plus job/group meta as `__meta_nomad_meta_`. A `?port=` query parameter filters to a single port label (e.g. `?port=metrics`). The endpoint would serve local client state only and require `node:read`.

Implementation sketch: ~200 lines in `command/agent/` plus a client method. Test plan: unit tests covering target-group rendering, port filtering, ACL enforcement, and IPv6 host-IP bracketing.

### Use-cases

Scraping per-allocation metrics with a node-local collector (e.g. a Prometheus agent per node). Each node's collector discovers its own allocations directly from the local client, so scrape-target discovery fans out to the clients instead of funneling through the servers — no server round-trip, no single discovery bottleneck, and discovery keeps working on a node even when servers are briefly unreachable.

Contributor guide

No contributing guide indexed for this repository

Research direction

Start in command/agent/ and trace the client HTTP API handlers and client method used for local allocation state. Add the Prometheus HTTP SD target-group response with port filtering, Nomad labels, ACL enforcement, and IPv6 host-IP handling, then cover rendering, filtering, ACL, and IPv6 behavior with unit tests.

Written by the indexing model from the issue text.

Assessment

Tech stack
go, prometheus
Domain
api, backend
Issue type
Feature
Difficulty
4/5
Estimated time
3-5 days
Activity status
Active
Clarity
Mostly clear
Newbie friendliness
68/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.