Kirthi Samson
Kirthi Samson

Reputation: 192

Add a custom tab on SpringBoot Admin Server

I'm fairly new to Spring. I am trying to integrate custom information from a service into Spring Boot Admin server dashboard.

Out of the box, the Spring boot admin server dashboard for a microservice contains tabs for Details, Metrics..etc. I need to add one or more custom tabs. I have one of my services serve a dummy endpoint (which would in future serve the custom tab) which I created by following this article. This endpoint extends the actuator.Endpoint class.

I have looked into Spring Boot Admin' Github, at both the Server and the UI but was unable to find a way to integrate a custom endpoint.

Any kind of help is appreciated. Thanks

Upvotes: 3

Views: 3336

Answers (2)

NickGreen
NickGreen

Reputation: 1752

In addition to @joshiste:

You can create a custom plugin by making sure your resources are added in the correct directories.

The admin project looks for the following directories:

registry.addResourceHandler(adminServerProperties.getContextPath() + "/**")
            .addResourceLocations("classpath:/META-INF/spring-boot-admin-server-ui/")
            .resourceChain(true)
            .addResolver(new PreferMinifiedFilteringResourceResolver(".min"));

    registry.addResourceHandler(adminServerProperties.getContextPath() + "/all-modules.css")
            .resourceChain(true)
            .addResolver(new ResourcePatternResolvingResourceResolver(resourcePatternResolver,
                    "classpath*:/META-INF/spring-boot-admin-server-ui/*/module.css"))
            .addResolver(new ConcatenatingResourceResolver("\n".getBytes()));

    registry.addResourceHandler(adminServerProperties.getContextPath() + "/all-modules.js")
            .resourceChain(true)
            .addResolver(new ResourcePatternResolvingResourceResolver(resourcePatternResolver,
                    "classpath*:/META-INF/spring-boot-admin-server-ui/*/module.js"))
            .addResolver(new PreferMinifiedFilteringResourceResolver(".min"))
            .addResolver(new ConcatenatingResourceResolver(";\n".getBytes()));

So make sure your js / css resources are added in /META-INF/spring-boot-admin-server-ui/etc. and have the correct names: module.js and module.css

UPDATE it looks like, it's not possible to add an extra tab to inject your custom plugin into. At least not i.c.w. Angular, like the default plugin. This is mainly due to the fact that all modules and js dependencies of SBA are minified in the build process, but the custom one isn't so you'll get JS errors like:

require isn't defined

On the following line of the custom module.js:

var angular = require('angular');

So the only way I see for now, is forking the entire SBA project and copy one of the default plugins as starting point of your own (eg. applications-metrics)

Upvotes: 0

joshiste
joshiste

Reputation: 2687

Currently there is no documentation on that. but it is possbible. Look at the spring-boot-admin-server-ui-activiti module. It adds a tab for a new endpoint.

Upvotes: 3

Related Questions