JavaMelody advertises itself as an opensource, lightweight, and production-ready monitoring tool that is easy to integrate with Spring Boot applications to provide statistics on HTTP requests, memory, CPU, Spring beans, scheduled background jobs, JDBC connections and more. It can be used in a CAS context to calculate response times and the number of component/request executions using charts and graphs to identify problem areas and assist with troubleshooting.
In this post, we will take a brief look at how JavaMelody may be configured to monitor CAS deployments. This tutorial specifically requires and focuses on:
7.0.x
21
Once you include the appropriate extension module in your CAS build, JavaMelody will be available at https://sso.example.org/cas/monitoring
to browse the monitoring reports. The report requires and forces authenticated access, so you will need to configure the credentials:
spring.security.user.name=javamelody
spring.security.user.password=M3ll0n
…and then you would be ready to browse:
In addition to the out-of-the-box metrics and statistics provided by JavaMelody, CAS itself instruments and tags several core components for monitoring and observations, such as the ticket registry, service registry, etc. You can see the stats for those in the JavaMelody report for Spring:
You can drill down into a tagged operation to, for instance, see how long CAS might take to locate and fetch a ticket. In this case, it would be extremely fast since the tickets by default are managed in runtime memory:
CAS components are not tied to JavaMelody at compile-time for monitoring and observations. Certain Spring beans annotated with @Controller
, @RestController
, @Service
, @Scheduled
, and many more are monitored automatically. If you want to monitor method calls and component invocations on other types of Spring beans, you can add @MonitoredWithSpring
on those classes or methods, which is an annotation that is provided by JavaMelody, or if you prefer, you can use the CAS equivalent annotation @Monitorable
. If you need to, you can also configure your annotation, i.e. @MyAnnotation
, for other monitoring purposes and allow JavaMelody to locate and monitor your components separately:
@Bean
public MonitoringSpringAdvisor myAdvisor() {
return new MonitoringSpringAdvisor(
new AnnotationMatchingPointcut(MyAnnotation.class, null));
}
If you have questions about the contents and the topic of this blog post, or if you need additional guidance and support, feel free to send us a note and ask about consulting and support services.
I hope this review was of some help to you and I am sure that both this post as well as the functionality it attempts to explain can be improved in any number of ways. Please feel free to engage and contribute as best as you can.
Happy Coding,
Monday-Friday
9am-6pm, Central European Time
7am-1pm, U.S. Eastern Time
Monday-Friday
9am-6pm, Central European Time