lang="en-US"> Lightbend Monitoring: Lagom - Knoldus Blogs
Knoldus Blogs

Lightbend Monitoring: Lagom

Reading Time: 3 minutes

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.
  • 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
Exit mobile version