I have three healthy services which I can see on consul web UI, one of them being consul itself and the two other being defined in the configuration file like so
{
"services": [
{
"name": "foo1.bar.dev",
"address": "10.133.114.235",
"port": 8010,
"check":
{
"name": "GET Check",
"http": "http://10.133.114.235:8010",
"method": "GET",
"interval": "5s",
"timeout": "1s"
}
}
]
}
Now in the web UI I can see that each service (consul, foo1.bar.dev and foo2.bar.dev) have 1 instance each (where each instance’s name is the same as the service itself, thus foo1.bar.dev, foo2.bar.dev and consul).
The problem is that when I try to iterate over them using snippet from the Readme file, namely
{{ range services }}
svc: {{ .Name }}
{{ range service .Name }}
test: {{ .Name }}
{{ end }}{{ end }}
I’ll only see consul. The other two will not appear because {{ range service.Name }}
will return an empty array.
svc: consul
test: consul
svc: foo1.bar.dev
svc: foo2.bar.dev
I can’t figure out why a service appears in the list of services but then it won’t appear when I try to fetch it via range service
.