spring-boot-admin icon indicating copy to clipboard operation
spring-boot-admin copied to clipboard

Multiple instances of same application don't show up

Open timwebster9 opened this issue 10 years ago • 11 comments

Hi,

If I have more than one instance of the same application (running on random ports and identified by different instance ids), only one will show up in the GUI.

They all show up in Eureka...is there something I need to configure somewhere to get them all to show up in Spring Boot Admin?

Thanks

timwebster9 avatar Dec 10 '15 17:12 timwebster9

You don't have to configure this explicit - it should just work. The applications are identified by their health-url. You should check them for being unique.

:information_source: The ApplicationDiscoveryListener is responsible for registering the discovered ServiceInstances, currently it just uses the informations exposed by the ServiceInstance-interface, therefore it might be necessary that you override the convert() method and use the health-url provided by the EurekaServiceInstance.

Also you could turn on the DEBUG logging for de.codecentric.boot.admin.registry.ApplicationRegistry. In case all your apps are using the same health-url there should appear a "Application {} refreshed" logmessage.

p.s. I just tested it once again and couldn't reproduce your issue

joshiste avatar Dec 10 '15 20:12 joshiste

Hi,

Won't the health URLs be unique anyways because the services are on different ports? I turned on the debug you suggested, and here's what I see:

2015-12-11 09:39:23.674 DEBUG 5516 --- [pool-8-thread-1] d.c.b.a.registry.ApplicationRegistry     : Application Application [id=3e94bdc4, name=UI-SERVER, managementUrl=http://KIT1030.hal.co.uk:58570/admin, healthUrl=http://KIT1030.hal.co.uk:58570/admin/health, serviceUrl=http://KIT1030.hal.co.uk:58570] refreshed
2015-12-11 09:39:23.674 DEBUG 5516 --- [pool-8-thread-1] d.c.b.a.registry.ApplicationRegistry     : Application Application [id=83624425, name=ADMINSERVER, managementUrl=http://KIT1030:9011/admin, healthUrl=http://KIT1030:9011/admin/health, serviceUrl=http://KIT1030:9011] refreshed
2015-12-11 09:39:23.674 DEBUG 5516 --- [pool-8-thread-1] d.c.b.a.registry.ApplicationRegistry     : Application Application [id=e29f292f, name=RESOURCE-SERVER, managementUrl=http://KIT1030.hal.co.uk:51684/admin, healthUrl=http://KIT1030.hal.co.uk:51684/admin/health, serviceUrl=http://KIT1030.hal.co.uk:51684] refreshed
2015-12-11 09:39:23.675 DEBUG 5516 --- [pool-8-thread-1] d.c.b.a.registry.ApplicationRegistry     : Application Application [id=4b47c4c7, name=AUTH-SERVER-KERBEROS, managementUrl=http://KIT1030:9999/admin, healthUrl=http://KIT1030:9999/admin/health, serviceUrl=http://KIT1030:9999] refreshed
2015-12-11 09:39:23.675 DEBUG 5516 --- [pool-8-thread-1] d.c.b.a.registry.ApplicationRegistry     : Application Application [id=39409399, name=GATEWAY-SERVER, managementUrl=http://KIT1030.hal.co.uk:8080/admin, healthUrl=http://KIT1030.hal.co.uk:8080/admin/health, serviceUrl=http://KIT1030.hal.co.uk:8080] refreshed

The RESOURCE-SERVER is the application where there are two instances, as you can see it can only see one for some reason.

When you tested it, you didn't have to do anything to make the health URLs unique?

timwebster9 avatar Dec 11 '15 09:12 timwebster9

Won't the health URLs be unique anyways because the services are on different ports?

Yes, exactly.

Did you check the Eureka registry for having both servers registered?

joshiste avatar Dec 11 '15 14:12 joshiste

Yes they are both registered (each with unique id):

RESOURCE-SERVER n/a (2) (2) UP (2) - resource-server:d9d4b97ea64ef94038d325607dbb2122 , resource-server:3c1bc95efa17ccc44da815cbd7b72e55

timwebster9 avatar Dec 11 '15 14:12 timwebster9

Weird. Do you have a sample project for me to reproduce this?

joshiste avatar Dec 11 '15 22:12 joshiste

Yep (attached).

  1. start eureka server
  2. start admin server
  3. start 2 instances of resource server
  4. observe both instances show up in Eureka, and only one in Admin Server admin-server-demo.zip

timwebster9 avatar Dec 12 '15 09:12 timwebster9

In the sample project I provided I am using @EnableDiscoveryClient on the resource server. I just tried it using the Spring Boot Admin Client (and @EnableEurekaClient) instead, and it works. So I guess the problem is somewhere with the 'discovery client'.

timwebster9 avatar Dec 12 '15 09:12 timwebster9

Ok I can reproduce the error and yes it's a problem with the discovery client. It looks like when fetching the registry only one instance is stored in the clients local registry.

I did though managed to get all instances show up in the admin by setting unique euraka.instance.hostname.

Doing a bit of debugging I found out, that the hostname is used as key for storing the InstanceInfo in com.netflix.discovery.shared.Application (since no UniqueIdentifier is set). So you have to use unique hostnames. So I guess when you test ribbon in this scenario you would see that the load won't be balanced.

I'm closing this issue since it is related to Eureka and not Spring Boot Admin.

joshiste avatar Dec 13 '15 01:12 joshiste

I think you can also set eureka.instance.metadataMap.instanceId to something unique and that will work. For example setting it to ${ spring.application.name}:${server.port} would generate an unique instance. I have been using Spring Boot Admin with 2 instance on the same host without different host names without issue and I believe this is how that is being achieved.

-Steve On Dec 12, 2015 8:22 PM, "Johannes Edmeier" [email protected] wrote:

Ok I can reproduce the error and yes it's a problem with the discovery client. It looks like that when fetching the registry only one instance is stored in the clients local registry.

I did though managed to get all instances show up in the admin by setting different euraka.instance.hostname.

Doing a bit of debugging I found out, that the key for storing the InstanceInfo in com.netflix.discovery.shared.Application is the hostname (since no UniqueIdentifier is set).

So I'm closing this issue since it is related to Eureka and not Spring Boot Admin.

— Reply to this email directly or view it on GitHub https://github.com/codecentric/spring-boot-admin/issues/134#issuecomment-164208504 .

steve-oakey avatar Dec 13 '15 01:12 steve-oakey

Hi,

OK I've tried both the approaches mentioned by @joshiste and @steve-oakey, and neither of them work. Let me know if I'm doing something wrong.

  • if I set eureka.instance.hostname to anything other than the valid hostname of the machine the service is running on, then the URLs for the endpoints will be wrong and nothing will work. E.g. if you set the second instance to localhost2, then the health URL will be http://localhost2:9000/admin/health, which is obviously invalid. I guess we could put some alias in the DNS but that is going too far.
  • the metadataMap option doesn't work. I already have a unique eureka.instance.instanceId using ${spring.application.name}:${spring.application.instance_id:${random.value}}. If i put that into eureka.instance.metadataMap.instanceId as well (or just on its own), it makes no difference. Also, I'm using random ports (server.port: 0), so using ${server.port} to make it unique doesn't work because it shows up as port 0 in Eureka.

@steve-oakey do you use random ports for your services? It seems like you got it to work but I'm not sure how - can you share your configuration (or at least the relevant parts)?

Incidentally, I think the key problem in com.netflix.discovery.shared.Application caused a similar problem that my colleague found using Turbine, which is why I started looking into this in the first place...

Thanks,

timwebster9 avatar Dec 13 '15 11:12 timwebster9

apologies to @steve-oakey - using eureka.instance.metadataMap.instanceId DOES work (when I use a random value as part of the instanceId). I think I didn't wait long enough for the registration to happen before I posted. This solves my problem. Thanks to both of you for your help..:-)

timwebster9 avatar Dec 13 '15 11:12 timwebster9