Elasticsearch

The Elasticsearch reporter works with both 1.x and 2.x versions of Elasticsearch and supports both Akka and Lagom instrumentation.

Cinnamon dependency

First make sure that your build is configured to use the Cinnamon Agent.

Reporter dependency

Add the Elasticsearch Report plugin dependency to your build:

sbt
libraryDependencies += Cinnamon.library.cinnamonCHMetricsElasticsearchReporter
Maven
<dependency>
    <groupId>com.lightbend.cinnamon</groupId>
    <artifactId>cinnamon-chmetrics-elasticsearch-reporter_2.11</artifactId>
    <version>2.5.2</version>
</dependency>
Gradle
dependencies {
  compile group: 'com.lightbend.cinnamon', name: 'cinnamon-chmetrics-elasticsearch-reporter_2.11', version: '2.5.2'
}

Reporter configuration

Below is the configuration needed to set up either version of the Elasticsearch reporter. The Reference tab shows all the configurable settings for the Elasticsearch reporter.

Required
cinnamon.chmetrics {
  reporters += elasticsearch-reporter
}
Reference
cinnamon.chmetrics {
  elasticsearch-reporter {

    # A list of hosts used to connect to elasticsearch.
    # Must be in the format `[http://][username:password@]hostname:port`.
    hosts = ["localhost:9200"]

    # Username and password to be used with all hosts (that don't define credentials directly).
    # Basic authentication is enabled when both username and password are non-empty.
    basic-auth {
      username = ""
      password = ""
    }

    # Milliseconds to wait for an established connection, before the next host in the list is tried.
    timeout = 1000

    # Defines how many metrics are sent per bulk requests.
    bulksize = 2500

    # The name of the index to write to, defaults to metrics.
    index = "cinnamon-metrics"

    # The date format to make sure to rotate to a new index.
    index-date-format = "yyyy-MM"

    # The field name of the timestamp (kibana default is @timestamp).
    timestamp-field-name = "@timestamp"

    # Frequency with which to report metrics.
    frequency = 10s

    # JSON files containing index mappings.
    # Default mapping will be applied if no file is specified.
    index-mapping-file-names = ["cinnamon_metrics.json"]

    percolation {
      # MetricFilter to define which metrics should be percolated.
      filter = "empty-filter"

      empty-filter {
        filter-class = "com.lightbend.cinnamon.chmetrics.elasticsearch.EmptyFilter"
      }

      # Implementation of the Notifier interface, which is executed upon a matching percolator.
      notifier = "empty-notifier"

      empty-notifier {
        notifier-class = "com.lightbend.cinnamon.chmetrics.elasticsearch.EmptyNotifier"
      }
    }
  }
}

Note: These settings are defined in the reference.conf. You only need to specify any of these settings when you want to override the defaults.

HTTP authentication

To set credentials for Elasticsearch using HTTP Basic Authentication, configure the basic-auth section for the reporter:

cinnamon.chmetrics {
  reporters += elasticsearch-reporter
  elasticsearch-reporter {
    hosts = ["https://somewhere.org:9200"]
    basic-auth {
      username = "elastic"
      password = "changeme"
    }
  }
}

You can specify that connections should be secured using SSL/TLS by including the https scheme.

The credentials can also be set individually on each host (and this will be selected over the global basic-auth configuration):

cinnamon.chmetrics {
  reporters += elasticsearch-reporter
  elasticsearch-reporter {
    hosts = ["https://elastic:changeme@somewhere.org:9200"]
  }
}

Host and application identifiers

The host and application identifiers reported to Elasticsearch are based on the shared Cinnamon metadata, and will default to the local host name and the Java main class. To configure these, use the cinnamon.host and cinnamon.application settings. For example:

cinnamon {
  host = "somewhere"
  application = "awesome-sauce"
}