Reading API metadata from deployed spring boot applications on a server

Viewed 337

I am trying to build an automated API reporting capability for which we need to scan a Linux server for all deployed APIs( spring boot apps). Once I get some metadata about the dpeloyed APIS, I want to hit the actuator endpints and capture more metadata like memory etc of deployed apis.

Is there a way I can scan this? Any help will be appreciated. I googled but its not matching what I need. Earlier the idea was to hit the zuul gateway and get information but we have many applications deployed on multiple servers, so not sure how it will work.

Update: Since people aren't getting my question. Lets say I have deployed 10 services on my server. I need to call the actuator endpoints of these 10 services, but I do not know the URL's of each service.So How do I determine it dynamically, without hardcoding the hostname/context:port of each service? I should be able to scan all the deployed apps and get their service URI and then give it to an aggregator service which will call the actuator endpoint of all services. No hardcoding of any service URI in anywhere. This way, when a new service is deployed on the server, I do not want the application developers to go and update a file with their service url.

4 Answers

The normal way of doing this is by spinning up a grafana instance for a fancy UI. Spring has prometheus support out of the box that exposes all kinds of metrics like memory usage, hits to your MVC controllers and so on.

Giving a concrete use case will be helpful. But for what I am able to understand, I would suggest you this :

  1. Create a wrapper custom actuator that will be used to get informations with the SNMP protocol via SNMP4J
  2. Use the internal API of a monitoring tool such a Grafana

In the past, I've used Spring Cloud Discovery for this.
I'd have my apps, using the Eureka Discovery Client, register themselves with a Eureka Server.

Then, using a script/reporting application, ask Eureka Server for all registered apps (/eureka/apps), from which you can get all the information required to load the data for each API.

enter image description here

I think your question lacks detail about the platform where you run those API's, but I'll explain high level how this would work in a kubernetes cluster.

Assuming a kubernetes environment, you can deploy a Prometheus server to scrape metrics from the different API's.

For each API you should deploy proper resources into kubernetes to support discovery of the API's and prometheus scraping (Service, ServiceMonitor) and need to setup Spring Boot actuator to provide a scraping endpoint (e.g. using micrometer-registry-prometheus). Note that this will publish default metrics available in Spring Boot (e.g. CPU, memory, ...), but you can define any other custom metric, business or technical, you could require.

At this point, prometheus should be capturing all metrics published by the API's, so you need a way to visualize all this. For this topic, Grafana is the tool, you can create dashboards based on your requirements to display all these information.

High level, this is the way, but of course specific for a kubernetes platform. If you are using a different platform, similar setup can be considered (not sure about the discovery process)

Related