Apereo CAS - Monitoring with JavaMelody

Posted by Misagh Moayyed on April 24, 2023 · 5 mins read ·
Content Unavailable
Your browser is blocking content on this website. Please check your browser settings and try again.

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:

Configuration

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:

CAS Components

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:

Custom Components

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));
}

Need Help?

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.

So…

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,

Misagh Moayyed