Accessing nomad agent's consul configuration from a job

I’m bootstrapping a nomad cluster, and my agents have consul { address = <ip> } configured.

Can I access that configuration from my jobs? I’d like to use something like ${attr.consul.addr}, but it doesn’t appear to be set. I’m not using consul connect.

I can set a custom meta field, but it seems pointless to set a value with the same semantic meaning in two different locations

@sbaildon Assuming your service has a designated port (and you know your Consul agent’s port) you could use the NOMAD_PORT_<label> environment variable and tack on the known port for the local Consul agent.

Not tested, but I’ve done something similar to talk to to the local Nomad agent.

I’ve not used this yet either, but I believe Nomad’s Task API could also achieve what you want, as you could query the local Nomad agent’s API to get it’s config for Consul.

Nomad Task API: Task HTTP API | Nomad | HashiCorp Developer
Nomad API (Query Self):