Spring-boot-admin: Issue with [object Object] as instance id

Created on 4 Jun 2020  路  7Comments  路  Source: codecentric/spring-boot-admin

App info:

Spring boot version: 2.2.7.RELEASE
Sprint boot admin version: 2.2.3
spring-cloud.version: Hoxton.SR4

I'm registering my applications to spring boot admin server using eureka discovery. Unfortunately instance ids on spring boot admin server are [object Object] which seems like a javascript issue of UI.

issue image

Therefore I cant see any of the metrix, mapping or else. When I open an instance, the URL is something like this: http://localhost:8081/instances/[objec Object]/details

bug waiting-for-feedback

Most helpful comment

You could use the AdminServerModule jackson module added in 2.2.3

All 7 comments

could you please show me the http response from the /applications endpoint? I'd guess you have some custom jackson config messing up the server response...

Sure.

{
   "JSON":[
      {
         "name":"SPRING-BOOT-ADMIN",
         "status":"UP",
         "statusTimestamp":1591285170228,
         "instances":[
            {
               "id":{
                  "value":"a51164ac99d1"
               },
               "version":4,
               "registration":{
                  "name":"SPRING-BOOT-ADMIN",
                  "managementUrl":"http://127.0.0.1:8081/actuator",
                  "healthUrl":"http://127.0.0.1:8081/actuator/health",
                  "serviceUrl":"http://127.0.0.1:8081",
                  "source":"discovery",
                  "metadata":{
                     "startup":"-1612418362",
                     "management.port":"8081"
                  }
               },
               "registered":true,
               "statusInfo":{
                  "status":"UP",
                  "details":{
                     "reactiveDiscoveryClients":{
                        "status":"UP",
                        "details":{
                           "Simple Reactive Discovery Client":{
                              "status":"UP",
                              "details":{
                                 "services":[

                                 ]
                              }
                           },
                           "Spring Cloud Eureka Reactive Discovery Client":{
                              "status":"UP",
                              "details":{
                                 "services":[
                                    "spring-boot-admin",
                                    "service-1"
                                 ]
                              }
                           }
                        }
                     },
                     "hystrix":{
                        "status":"UP"
                     },
                     "diskSpace":{
                        "status":"UP",
                        "details":{
                           "total":164188123136,
                           "free":40267452416,
                           "threshold":10485760
                        }
                     },
                     "ping":{
                        "status":"UP"
                     },
                     "discoveryComposite":{
                        "status":"UP",
                        "details":{
                           "discoveryClient":{
                              "status":"UP",
                              "details":{
                                 "services":[
                                    "spring-boot-admin",
                                    "service-1"
                                 ]
                              }
                           },
                           "eureka":{
                              "description":"Remote status from Eureka server",
                              "status":"UP",
                              "details":{
                                 "applications":{
                                    "SPRING-BOOT-ADMIN":1,
                                    "SERVICE-1":1
                                 }
                              }
                           }
                        }
                     },
                     "refreshScope":{
                        "status":"UP"
                     }
                  },
                  "up":true,
                  "unknown":false,
                  "offline":false,
                  "down":false
               },
               "statusTimestamp":1591285170228,
               "info":{
                  "values":{

                  }
               },
               "endpoints":[
                  {
                     "id":"caches",
                     "url":"http://127.0.0.1:8081/actuator/caches"
                  },
                  {
                     "id":"loggers",
                     "url":"http://127.0.0.1:8081/actuator/loggers"
                  },
                  {
                     "id":"health",
                     "url":"http://127.0.0.1:8081/actuator/health"
                  },
                  {
                     "id":"refresh",
                     "url":"http://127.0.0.1:8081/actuator/refresh"
                  },
                  {
                     "id":"env",
                     "url":"http://127.0.0.1:8081/actuator/env"
                  },
                  {
                     "id":"heapdump",
                     "url":"http://127.0.0.1:8081/actuator/heapdump"
                  },
                  {
                     "id":"features",
                     "url":"http://127.0.0.1:8081/actuator/features"
                  },
                  {
                     "id":"scheduledtasks",
                     "url":"http://127.0.0.1:8081/actuator/scheduledtasks"
                  },
                  {
                     "id":"mappings",
                     "url":"http://127.0.0.1:8081/actuator/mappings"
                  },
                  {
                     "id":"archaius",
                     "url":"http://127.0.0.1:8081/actuator/archaius"
                  },
                  {
                     "id":"beans",
                     "url":"http://127.0.0.1:8081/actuator/beans"
                  },
                  {
                     "id":"configprops",
                     "url":"http://127.0.0.1:8081/actuator/configprops"
                  },
                  {
                     "id":"threaddump",
                     "url":"http://127.0.0.1:8081/actuator/threaddump"
                  },
                  {
                     "id":"metrics",
                     "url":"http://127.0.0.1:8081/actuator/metrics"
                  },
                  {
                     "id":"conditions",
                     "url":"http://127.0.0.1:8081/actuator/conditions"
                  },
                  {
                     "id":"service-registry",
                     "url":"http://127.0.0.1:8081/actuator/service-registry"
                  },
                  {
                     "id":"info",
                     "url":"http://127.0.0.1:8081/actuator/info"
                  }
               ],
               "tags":{
                  "values":{

                  }
               }
            }
         ]
      },
      {
         "name":"SERVICE-1",
         "buildVersion":{
            "value":"0.0.1-SNAPSHOT"
         },
         "status":"UP",
         "statusTimestamp":1591285160458,
         "instances":[
            {
               "id":{
                  "value":"73a78c62dc44"
               },
               "version":3,
               "registration":{
                  "name":"SERVICE-1",
                  "managementUrl":"http://127.0.0.1:8080/service1/actuator",
                  "healthUrl":"http://127.0.0.1:8080/service1/actuator/health",
                  "serviceUrl":"http://127.0.0.1:8080/service1",
                  "source":"discovery",
                  "metadata":{
                     "contextPath":"/service1",
                     "user.name":"user",
                     "management.port":"8080",
                     "user.password":"password"
                  }
               },
               "registered":true,
               "statusInfo":{
                  "status":"UP",
                  "details":{
                     "hystrix":{
                        "status":"UP"
                     },
                     "diskSpace":{
                        "status":"UP",
                        "details":{
                           "total":164188123136,
                           "free":40267489280,
                           "threshold":10485760
                        }
                     },
                     "ping":{
                        "status":"UP"
                     },
                     "discoveryComposite":{
                        "status":"UP",
                        "details":{
                           "discoveryClient":{
                              "status":"UP",
                              "details":{
                                 "services":[
                                    "service-1",
                                    "spring-boot-admin"
                                 ]
                              }
                           },
                           "eureka":{
                              "description":"Remote status from Eureka server",
                              "status":"UP",
                              "details":{
                                 "applications":{
                                    "SPRING-BOOT-ADMIN":1,
                                    "SERVICE-1":1
                                 }
                              }
                           }
                        }
                     },
                     "refreshScope":{
                        "status":"UP"
                     }
                  },
                  "up":true,
                  "unknown":false,
                  "offline":false,
                  "down":false
               },
               "statusTimestamp":1591285160458,
               "info":{
                  "values":{
                     "app":{
                        "description":"Sepehr Demo Service (info-decsription)",
                        "java":{
                           "version":1.8
                        },
                        "name":"Demo Service (info-name)",
                        "version":"1.0.0"
                     },
                     "tags":{
                        "environment":"Demo Service (info-environment)"
                     },
                     "build":{
                        "version":"0.0.1-SNAPSHOT",
                        "artifact":"service1",
                        "name":"service1",
                        "group":"com.example",
                        "time":"2020-06-04T14:58:11.836Z"
                     }
                  }
               },
               "endpoints":[
                  {
                     "id":"caches",
                     "url":"http://127.0.0.1:8080/service1/actuator/caches"
                  },
                  {
                     "id":"loggers",
                     "url":"http://127.0.0.1:8080/service1/actuator/loggers"
                  },
                  {
                     "id":"health",
                     "url":"http://127.0.0.1:8080/service1/actuator/health"
                  },
                  {
                     "id":"refresh",
                     "url":"http://127.0.0.1:8080/service1/actuator/refresh"
                  },
                  {
                     "id":"env",
                     "url":"http://127.0.0.1:8080/service1/actuator/env"
                  },
                  {
                     "id":"heapdump",
                     "url":"http://127.0.0.1:8080/service1/actuator/heapdump"
                  },
                  {
                     "id":"features",
                     "url":"http://127.0.0.1:8080/service1/actuator/features"
                  },
                  {
                     "id":"scheduledtasks",
                     "url":"http://127.0.0.1:8080/service1/actuator/scheduledtasks"
                  },
                  {
                     "id":"mappings",
                     "url":"http://127.0.0.1:8080/service1/actuator/mappings"
                  },
                  {
                     "id":"archaius",
                     "url":"http://127.0.0.1:8080/service1/actuator/archaius"
                  },
                  {
                     "id":"beans",
                     "url":"http://127.0.0.1:8080/service1/actuator/beans"
                  },
                  {
                     "id":"configprops",
                     "url":"http://127.0.0.1:8080/service1/actuator/configprops"
                  },
                  {
                     "id":"threaddump",
                     "url":"http://127.0.0.1:8080/service1/actuator/threaddump"
                  },
                  {
                     "id":"metrics",
                     "url":"http://127.0.0.1:8080/service1/actuator/metrics"
                  },
                  {
                     "id":"conditions",
                     "url":"http://127.0.0.1:8080/service1/actuator/conditions"
                  },
                  {
                     "id":"service-registry",
                     "url":"http://127.0.0.1:8080/service1/actuator/service-registry"
                  },
                  {
                     "id":"info",
                     "url":"http://127.0.0.1:8080/service1/actuator/info"
                  },
                  {
                     "id":"jolokia",
                     "url":"http://127.0.0.1:8080/service1/actuator/jolokia"
                  }
               ],
               "buildVersion":{
                  "value":"0.0.1-SNAPSHOT"
               },
               "tags":{
                  "values":{
                     "environment":"Demo Service (info-environment)"
                  }
               }
            }
         ]
      }
   ]
}

And I had this Bean:

@Bean
public ObjectMapper objectMapper(){
    ObjectMapper objectMapper = new ObjectMapper();
    SimpleModule module = new SimpleModule("RegistrationDeserializer", new Version(1, 0, 0, null, null, null));
    module.addDeserializer(Registration.class, new RegistrationDeserializer());
    objectMapper.registerModule(module);
    return objectMapper;
}

But I commented it and still not working.

The serialization of

"id":{ value":"a51164ac99d1" }
````
should be

"id":"a51164ac99d1"
````

That's right. Any ideas how can I fix this or whats causing the problem?

Ok, I removed the comment for my ObjectMapper bean I created earlier, and after spending some time on SBA source code, I found this instantIdMixin, so I added it to my object mapper and everything works fine:

@Bean
public ObjectMapper objectMapper(){
    ObjectMapper objectMapper = new ObjectMapper();
    SimpleModule module = new SimpleModule("RegistrationDeserializer", new Version(1, 0, 0, null, null, null));
    module.addDeserializer(Registration.class, new RegistrationDeserializer());
    objectMapper.registerModule(module);
    objectMapper.addMixIn(InstanceId.class, InstanceIdMixin.class);
    return objectMapper;
}

Its kinda weird that they were not part of default object mapper.

My issue is fixed but Im not gonna close this as it might need more investigation by you. Thank you.


I have also created a repository that can help people see the bigger fix of deploying service under tomcat, but you can also use it to recreate the problem by just commenting the object mapper bean.

Its here

You could use the AdminServerModule jackson module added in 2.2.3

This worked for me.. :) It sets the default object mapper for Spring.. and seems to sort the issue out..

@Configuration
class ApplicationConfiguration implements WebMvcConfigurer {
    @Bean(name = "jsonMapper")
    @Primary
    public ObjectMapper jsonMapper() {
        ObjectMapper mapper = new ObjectMapper();
        mapper.registerModule(new AdminServerModule(new String[]{".*password$"}));
        return mapper;
    }
    @Override
    public void configureMessageConverters(List<HttpMessageConverter<?>> converters) {
        converters.add(new MappingJackson2HttpMessageConverter(jsonMapper()));
    }
}
Was this page helpful?
0 / 5 - 0 ratings