Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Problem on getting latest application list programatically #3358

Open
Muyangmin opened this issue May 6, 2024 · 2 comments
Open

Problem on getting latest application list programatically #3358

Muyangmin opened this issue May 6, 2024 · 2 comments

Comments

@Muyangmin
Copy link

Spring Boot Admin Server information

  • Version: 2.7.14

  • Spring Boot version: 2.7.10

  • Configured Security: NONE

  • Webflux or Servlet application: Webflux

Client information

  • Spring Boot versions: 2.7.x

  • Used discovery mechanism: Eureka

  • Webflux or Servlet application: Servlet

Description

Sorry but I've really read the issue notes and asked a question on StackOverflow(Question Link Here) before, but got no answers for 10 days. This problem is really important for me so hope I can get some help here, Thanks!

Below is the question copy:

We have integrated spring-boot-admin into many projects. Now, due to some tricky network reasons, I am unable to access the built-in UI interface of SBA. Therefore, I would like to periodically retrieve the equivalent information from its interface programmatically and write it to the database, so that I can read and present it from another program.

The simplest way seems to be to curl the application interface, but considering the timing logic and SBA are in the same program, I want to minimize unnecessary network calls. After some preliminary research, I wrote the following code(in Kotlin):

Environment: Kotlin 1.9.22, SpringBoot 2.7.10, SpringBootAdmin 2.7.14.

//Autowired
private val registry: ApplicationRegistry

fun refreshAppRegistry() {
    //I want get it synchronously, so Flux etc is not needed
    val applications = registry.applications.collectList().block()?.filterNotNull().orEmpty()

    //Handle data, the way I retrieve fields just like:
    appName = app.name,
    serviceUrl = it.registration.serviceUrl.orEmpty(),
    managementUrl = it.registration.managementUrl,
    buildVersion = it.buildVersion?.value,
    instanceStatus = it.statusInfo.status,
}

However, I found that the information I retrieved seems to be somewhat delayed: changes in the actuator/info information (such as build.version) of the monitored application are NOT reflected in my program. I have to restart the admin program to get the latest information. Please advise me on what went wrong, thank you!

@erikpetzold
Copy link
Member

erikpetzold commented May 6, 2024

Hi @Muyangmin,

using registry.getApplications() should be the correct way to access this information, this is also what the frontend calls to display the data (via ApplicationsController).

First you wrote the changes are delayed (showing up a bit later), then you wrote you have to restart (otherwise there will be no updates at all?).

  • If the changes are deplayed, then some intervals for updates whithin SBA might be too high (spring.boot.admin.monitor.status-interval, spring.boot.admin.monitor.info-interval). Try to check the logs to see if Spring Boot Admin itself gets the new information.
  • If the changes are only shown after restart I guess you have an error in your update implementation.

Also check if the data that is not being updated is coming from the monitored applications or from eureka. Maybe the Admin Server itself does not fetch updates from eureka (registryFetchIntervalSeconds)?

As you can see, there could be many reasons. If you do not find a solution please provide more information (logs, configuration, more code, runnable example, ...)

@Muyangmin
Copy link
Author

Muyangmin commented May 7, 2024

Thanks for your detailed response. From the previous investigation, I can confirm that the information from SBA itself can be updated in a timely manner. Your reply has given me some new insights, and perhaps there are some potential issues in the infinite loop I use for updates. I will focus on investigating this aspect, and will reply here with any progress. 👍

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants