Hotpot
Hotpot is a framework on top of Spring Boot for building a central console of Microservices.
It allows you to quickly build a web app that brings together your services, their statuses, and metrics.
Main concepts
Service: an individual deployable artifact in your microservices universe, e.g.user-serviceService Metric: a measure of some aspect of aService, for example:- average-releases: average number of releases for the past 30 days - percentage-rollback: percentage of rollbacks for the past 30 days - doc-location: url of the service's web API documentation
Service Objective: a goal, rule, or guideline that you want aServiceto satisfy, expressed in terms of one or moreService Metrics, for example:- high-quality-release: average-releases > 1 AND percentage-rollback < 20% - well-documented: doc-location exists
Quick start
-
Set up a Spring Boot application, perhaps using Spring Initializr, or gradle init.
-
Import
hotpot-coreas a dependency. If you're using gradle:repositories { jcenter() } dependencies { implementation 'com.hotpot:hotpot-core:${version}' } -
Add the following configuration to your
application.yamlor equivalent:hotpot: web-api: enabled: <enabled> # default: true. Web API endpoints will be exposed. base-url: <base-url> # default: "". Web API endpoints will be exposed under the <base-url> sub-path metrics: enabled: <enabled> # default: false. Enable gathering and surfacing service level metrics and objectives.
-
Create (and wire) beans that implement the following interfaces:
- ServiceIdentityProvider (exactly 1): to provide all the service identifiers - ServiceMetaDataProvider (1 or more): to provide service metadata given a service identifier
Note: Services' metadata may come from multiple sources. In Hotpot, each
ServiceMetaDataProvidertherefore needs to set aprecedence. When constructing a service from the metadata provided by the multiple providers, the ones with higher precedence (larger number) will override the ones with lower precedence, if they both provide the same metadata field on the same service. -
To enable service metrics, set
hotpot.metrics.enabledto true, and create beans that implement the following interfaces:- ServiceMetricProvider (exactly 1): to provide all the service metrics - ServiceObjectiveProvider (exactly 1): to provide all the service objectives - ServiceDataProvider (1 or more): to provide the actual data for each metric defined in the ServiceMetricProvider
-
Start up your spring boot application.
-
curl localhost:8080/<base-ur>/serviceIdswill give you the IDs of all your services. -
With metrics enabled,
curl localhost:8080/<base-ur>/metrics/values/{serviceId}will give you all the current metrics for the serviceserviceId.
For the complete set of endpoints, see the public documentation.
Alternatively, import and run the Postman Collection locally.
Libraries
Popular libraries that make running a Hotpot app even easier include:
- hotpot-staticdata: Support file (
yaml) based service, metric, and objective definitions