Add Telemetry

This section describes how to set up Lightbend Telemetry to take advantage of Lightbend Console’s built in monitors. The main steps include:

  1. Verify Lightbend credentials and add them to the project
  2. Add the Telemetry plugin and enable Prometheus metrics

Credentials

Lightbend Telemetry requires commercial credentials. You should have a ~/.lightbend/commercial.credentials file with the following contents (if necessary, log into https://portal.lightbend.com/ReactivePlatform/EnterpriseSuiteCredentials to obtain your username and password):

realm = Bintray
host = dl.bintray.com
user = <your username>
password = <your password>

In the Akka orchestration example’s project directory, create a lightbend.sbt file with the following contents:

credentials += Credentials(Path.userHome / ".lightbend" / "commercial.credentials")
resolvers += "com-mvn" at "https://repo.lightbend.com/commercial-releases/"
resolvers += Resolver.url("com-ivy",
url("https://repo.lightbend.com/commercial-releases/"))(Resolver.ivyStylePatterns)

Enable Telemetry and Prometheus metrics

To enable Telemetry and Prometheus, edit the following files:

First, open project/plugins.sbt and add the Telemetry sbt-cinnamon plugin:

addSbtPlugin("com.lightbend.cinnamon" % "sbt-cinnamon" % "2.9.3")
resolvers += Resolver.url("lightbend-commercial", url("https://repo.lightbend.com/commercial-releases"))(Resolver.ivyStylePatterns)

Next, add the following configuration to src/main/resources/application.conf:

// Enable the prometheus exporter which will be scraped by ES.
// Configuration details are at https://developer.lightbend.com/docs/telemetry/current/plugins/prometheus/prometheus.html#configuration.
cinnamon.prometheus {
    exporters += http-server

http-server {
// Set this to listen on all interfaces, so it will listen on the container's external interface.
    host = "0.0.0.0"
    port = 9091
    }
}

cinnamon.application = "tutorial"

// The following lines are specific to the tutorial example app.
// Configuration details are at https://developer.lightbend.com/docs/telemetry/current/instrumentations/akka/actors.html#actor-settings.
cinnamon.akka {
    actors {
      // Export the tutorial's actors.
      "/user/*" {
          report-by = class
      }
    }
}

// Log to stdout for debugging purposes.
cinnamon.chmetrics {
   reporters += "console-reporter"
  }

Finally, modify build.sbt to enable Lightbend Telemetry and Prometheus discovery on the k8s deployment:

// Enable Lightbend Telemetry `Cinnamon` plugin.
enablePlugins(SbtReactiveAppPlugin, Cinnamon)

// Add Cinnamon library dependencies.
libraryDependencies ++= Vector(
    Cinnamon.library.cinnamonCHMetrics,
    Cinnamon.library.cinnamonAkka,
    Cinnamon.library.cinnamonAkkaHttp,
    Cinnamon.library.cinnamonJvmMetricsProducer,
    Cinnamon.library.cinnamonPrometheus,
    Cinnamon.library.cinnamonPrometheusHttpServer
)

// Endpoint for accessing cinnamon.
endpoints += TcpEndpoint("cinnamon", 9091, None)

// Annotations for Prometheus discovery.
annotations := Map(
    // enable scraping
    "prometheus.io/scrape" -> "true",
    "prometheus.io/port" -> "9091"
)

This includes an annotation on every pod so it will be scraped by the Prometheus instance in Lightbend Console. You are now ready to deploy the instrumented application.