Lightbend Monitoring: Lagom


Lightbend Monitoring provides insight into applications built with Lightbend technologies. It does so by instrumentation of frameworks like Akka and Lagom. The instrumentation is done by a Java agent (called Cinnamon) that runs when your application is starting up. It collects information in runtime based on the configurations that you have provided.

In this post, we would show the Circuit Breaker (CB) monitoring with Lagom. By default, Lagom enables CB for all the services. Circuit Breakers are used and configured on the client side, but the granularity and configuration identifiers are defined by the service provider. For more details on the Circuit breakers, read here.

circuit-breaker-states.png

In this post, we would try to setup a Lagom CB monitoring with Maven on a Java Project. For setting it up with sbt refer to this link.

First things first, the cinnamon agent is available from the Lightbend Commercial library, so you should have a commercial account with Lightbend.

    • In the .m2/settings.xml, you would have to add the server
    • <server>
       <id>lightbend-commercial</id>
       <username>d40ab051-XXXXXXXX-7b2cc62aa502@lightbend</username>
       <password>3cbebe2273745454666070f9d35b0f29bce779e1c</password>
       </server>
          
      
    • Next, add the Lightbend commercial repo
       <repositories>
            <repository>
                <id>lightbend-commercial</id>
                <name>Lightbend Commercial</name>
                <url>https://lightbend.bintray.com/commercial-releases</url>
            </repository>
      <repository>
            <id>lightbend-contrail</id>
            <name>Lightbend Contrail</name>
            <url>https://dl.bintray.com/typesafe/commercial-maven-releases</url>
          </repository>
    • Above 2 steps would ensure that you are able to download the commercial cinnamon agent from Lightbend.
    • Next, in the services that you would like to monitor, we would add the lagom dependencies

  • <!-- Adding dependency for monitoring -->
        <dependency>
           <groupId>com.lightbend.cinnamon</groupId>
           <artifactId>cinnamon-chmetrics_2.11</artifactId>
              <version>2.3.0</version>
             </dependency>
    
              <dependency>
                  <groupId>com.lightbend.cinnamon</groupId>
                  <artifactId>cinnamon-lagom_2.11</artifactId>
                  <version>2.3.0</version>
              </dependency>
    <dependency>
      <groupId>com.lightbend.cinnamon</groupId>
      <artifactId>cinnamon-akka_2.11</artifactId>
      <version>2.3.0</version>
    </dependency>
  • We have to add the cinnamon-akka dependency exclusively because of a bug which is not pulling it transitively as of this version.
  • In the application.conf, we would make the module relevant for monitoring and also tell that the monitored information needs to go to the console for now
  • lagom.spi.circuit-breaker-metrics-class = "cinnamon.lagom.CircuitBreakerInstrumentation"
    
    cinnamon.chmetrics.reporters += "console-reporter"
  • In our code example, we have a sayHelloThroughMeService which gets  a GET request. Further, it makes a call on the helloservice. Now the sayHelloThroughMeService acts as the client for the helloservice and calls the hello method on that service.
  • Screenshot from 2017-03-27 18-14-06
  • If you notice, the console, it starts reporting the CB statistics in the following way
  • -- Gauges -------------------3/27/17 4:48:45 PM =============================================================
    
    -- Gauges ----------------------------------------------------------------------
    circuit-breaker.hello.state
     value = 3  
    
    -- Histograms ------------------------------------------------------------------
    circuit-breaker.hello.latency
     count = 3 
     min = 18139411
     max = 169405057
     mean = 52801616.56
     stddev = 63411921.00
     median = 18488948.00
     75% <= 18488948.00
     95% <= 169405057.00
     98% <= 169405057.00
     99% <= 169405057.00
     99.9% <= 169405057.00
    
    -- Meters ----------------------------------------------------------------------
    circuit-breaker.hello.failure-counter
     count = 0 
     mean rate = 0.00 events/second
     1-minute rate = 0.00 events/second
     5-minute rate = 0.00 events/second
     15-minute rate = 0.00 events/second
    circuit-breaker.hello.success-counter
     count = 3 
     mean rate = 0.05 events/second
     1-minute rate = 0.09 events/second
     5-minute rate = 0.17 events/second
     15-minute rate = 0.19 events/second
    circuit-breaker.hello.throughput
     count = 3 
     mean rate = 0.05 events/second
     1-minute rate = 0.09 events/second
     5-minute rate = 0.17 events/second
     15-minute rate = 0.19 events/second
    circuit-breaker.hello.throughput-failure
     count = 0
     mean rate = 0.00 events/second
     1-minute rate = 0.00 events/second
     5-minute rate = 0.00 events/second
     15-minute rate = 0.00 events/second
  • Let us try to quickly read through the metrics. It show
    • A shows that the state of the CB
    • B shows the count that the service has been hit for
    • C shows the failure count
    • D shows success count and so on
  • All this visualization is on the console yet. next, we would try to integrate this with one of the visualization tools.
  • For downloading and making the code work on your system, you can pull the code from Knoldus Github Repo. PR’s welcome
Advertisements

About Vikas Hazrati

Vikas is the Founding Partner @ Knoldus which is a group of software industry veterans who have joined hands to add value to the art of software development. Knoldus does niche Reactive and Big Data product development on Scala, Spark and Functional Java. Knoldus has a strong focus on software craftsmanship which ensures high-quality software development. It partners with the best in the industry like Lightbend (Scala Ecosystem), Databricks (Spark Ecosystem), Confluent (Kafka) and Datastax (Cassandra). To know more, send a mail to hello@knoldus.com or visit www.knoldus.com
This entry was posted in Microservices, Scala and tagged , , , , . Bookmark the permalink.

One Response to Lightbend Monitoring: Lagom

  1. Tathagata says:

    Waiting for Part 2 – where integration with Visualization tool would be discussed.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s