I recently wrote a tutorial demonstrating how to leverage the integrations between Spring Boot Actuator and Pivotal Cloud Foundry 1.11, postedhere in the Pivotal content library.
Here is a quick summary of the articles content:
Adding Actuator to your Spring Boot application deployed on Pivotal Cloud Foundry gets you the following production-ready features:
- Health Check column & expanded information in Instances section
- git commit id indicator, navigable to your git repo
- Summary git info under Settings tab (also navigable to repo)
- Runtime adjustment of logging levels, exposed via Actuator endpoints
- Heap Dump*
- View Trace*
- View Threads, dump/download for further analysis*
* New in Pivotal Cloud Foundry 1.11
TL;DR: Pivotal Cloud Foundry 1.11 provides somereally nice integrations with Spring Boot Actuator-enabled applications/microservices, giving you vital tools for monitoring, introspection, and troubleshooting quickly and effectively.
Like this post?Follow me on Twitter for more! And be sure to check out the Related Posts below.
A Span is the basic unit of work. For example, sending an RPC is a new span, as is sending a response to an RPC. Span’s are identified by a unique 64-bit ID for the span and another 64-bit ID for the trace the span is a part of. Spans also have other data, such as descriptions, key-value annotations, the ID of the span that caused them, and process ID’s (normally IP address). Spans are started and stopped, and they keep track of their timing information. Once you create a span, you must stop it at some point in the future. A set of spans forming a tree-like structure called a Trace. For example, if you are running a distributed big-data store, a trace might be formed by a put request.
(click/tap to enlarge)
spring.application.name=sz-provider-service
spring.application.name=sz-consumer-serviceserver.port=8081
Just a quick tip for the Spring fans out there…
I was leading a workshop yesterday and this question arose: Is it possible to filter requests by header content using Spring’s various request mapping (@RequestMapping, @GetMapping, @PostMapping, et al) annotations?
Not only is it possible, it’s easy, and the implementation is concise & clean! Let’s take a look.
Here is a simple example that filters based upon the content-type of the header:
To test this, simply visit theSpring Initializr, create a simple Spring Boot app with a single dependency (Web), download & unzip it, and add the code above using your favorite IDE. Then build & run it (of course)! 😉
Usinghttpie (which is quickly becoming my favorite CLI HTTP client), we can verify our results:
NOTE: The above examples use httpie “shorthand”, which assumes localhost when the base URL is omitted.
That’s all for now, but stay tuned (orfollow me on Twitter) for more quick (or more lengthy) Spring tips!
Cheers,
Mark
Click here for additional information
Just a quick tip for the Spring fans out there…
If you’ve decided to try out Spring Boot Actuator – and if you haven’t you really should! – you may have run into one of two interesting hitches that are easily resolved:
In the case of point #1 above, you may see this in your logs:
s.b.a.e.m.MvcEndpointSecurityInterceptor :Full authentication is required to access actuator endpoints. Consider adding Spring Security or set ‘management.security.enabled’ to false.
For testing, it’s adequate and acceptable to simply add the suggested entry to your app’sapplication.properties file:
management.security.enabled=false
This is far less likely to be a suitable solution for production apps, though. 🙂 Enabling Spring Security properly to secure access to your application is a far more production-ready option.
If you can load successfully the various Spring Boot Actuator endpoints but get a 404 error on /actuator, the primary (navigable) Actuator endpoint, you are hitting a different (yet also easily resolved) snag. The hint is in how I phrased the difficulty: the primary (navigable) Actuator endpoint.
In order to access /actuator, which uses hypermedia to provide a navigable structure of links to Actuator endpoints, you must include HATEOAS (spring-boot-starter-hateoas) on your classpath. Adding this to your POM will fix that nicely:
<dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-hateoas</artifactId></dependency>
That’s all for now, but stay tuned (orfollow me on Twitter) for more quick or lengthy Spring tips!
Cheers,
Mark
Click here for more information about Spring Boot Actuator.