Skip to content
This repository has been archived by the owner on Nov 3, 2017. It is now read-only.

Record statistics for CAS events in Redis server

Dmitriy Kopylenko edited this page Oct 1, 2013 · 6 revisions

Version 1.9 introduces the facility to record statistics for different CAS events in Redis server as simple atomic counters values with keys containing dates in yyyy-MM-dd format. Currently 2 CAS events are captured and recorded in Redis with daily stat keys - namely CasSsoSessionEstablishedEvent with corresponding cas:sso-sessions-established:{yyyy-MM-dd} Redis counter key and CasSsoServiceTicketValidatedEvent with corresponding cas:st-validated:{yyyy-MM-dd} Redis counter key.

This facility opens up a possibility to easily gather simple stats about CAS events which then could be used to build reporting tools on top of it without requiring writing code for parsing unstructured log files data, etc.

In order for this facility to work, one would need to install and start a Redis server.

Configuration

  • Expose CAS events
<beans xmlns="http://www.springframework.org/schema/beans"
       xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
       xmlns:aop="http://www.springframework.org/schema/aop"
       xmlns:cas="http://unicon.net/schema/cas"
       xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd
       http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop.xsd
       http://unicon.net/schema/cas http://unicon.net/schema/cas/cas-addons.xsd">

    <aop:aspectj-autoproxy/>

    <cas:default-authentication-support/>

    <cas:default-events-publisher/>

</beans>
  • Configure Redis connection factory and corresponding Redis recording event listeners
<beans xmlns="http://www.springframework.org/schema/beans"
       xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"              
       xmlns:cas="http://unicon.net/schema/cas"
       xsi:schemaLocation="http://www.springframework.org/schema/beans
       http://www.springframework.org/schema/beans/spring-beans.xsd       
       http://unicon.net/schema/cas http://unicon.net/schema/cas/cas-addons.xsd">

    <bean id="jedisConnectionFactory" class="org.springframework.data.redis.connection.jedis.JedisConnectionFactory"/>

    <cas:events-redis-recorder 
         event-type="sso-session-established" 
         redis-connection-factory="jedisConnectionFactory"/>

    <cas:events-redis-recorder 
         event-type="service-ticket-validated" 
         redis-connection-factory="jedisConnectionFactory"/>

</beans>

Usage

The stats can be accessed in Redis server like so (example of redis-cli command line client):

redis 127.0.0.1:6379> get cas:sso-sessions-established:2013-10-01
"6"

redis 127.0.0.1:6379> get cas:sso-sessions-established:2013-09-30
"2"

redis 127.0.0.1:6379> get cas:st-validated:2013-10-01
"1"
Clone this wiki locally