Add Lightbend 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
Note

See Lightbend Telemetry getting started documentation for more information about how to setup your project to use it.

Credentials

To gain access to Lightbend Telemetry you must have a Lightbend subscription and Lightbend account.

Once you have logged in, the Lightbend platform credentials guide contains instructions for configuring your sbt, maven or gradle project to access Lightbend’s commercial dependencies, including Telemetry. If you have previously used a username and password to configure your Lightbend Commercial Credentials, the guide will instruct you how to update to using the new scheme.

Note

The URLs generated as part of your Lightbend platform credentials should not be committed to public source control repositories.

If you do not have a Lightbend subscription, please contact us to request an evaluation.

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.15.1")
Note

See Lightbend Telemetry release notes to check which is the most recent version.

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

cinnamon {
    application = "akka-cluster-example"

    // 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.
    akka {
        actors {
            "/user/*" {
            report-by = class
            }
        }
    }

    // Enable the prometheus exporter which will be scraped by Console.
    // Configuration details are at https://developer.lightbend.com/docs/telemetry/current/plugins/prometheus/prometheus.html#configuration.
    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
        }
    }
    // Log to stdout for debugging purposes.
    chmetrics {
        reporters += "console-reporter"
    }
}

Include port 9091 to the list of exposed ports. Port 9091 will be used to export Prometheus metrics:

dockerExposedPorts += 9091

Now add this at the end of build.sbt file to enable Cinnamon plugin and add library dependencies:

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

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

Finally, ensure the metric port is exposed. This should already be done for you if you copied the akka-cluster-example.yaml. This should be in the deployment spec:

ports:
  - name: metrics
    containerPort: 9091

And this in the service spec:

ports:
  - name: metrics
    port: 9091
    targetPort: 9091