alonsodomin / kamon-cloudwatch   1.1.5

GitHub

Kamon extension to ship Kamon metrics to AWS Cloudwatch

Scala versions: 2.13 2.12 2.11 2.10

Kamon AWS Cloudwatch Extension

Build Status GitHub release Maven Central Mergify Status

Overview

A simple Kamon extension to ship metrics data to Cloudwatch using Amazon's async client.

Note: This project has been initially forked from Timeout's kamon-cloudwatch but evolved separately as the original one has fallen out of maintenance.

Version Compatibility Matrix

The following table maps Kamon core version with the version of this library:

Kamon Core Kamon CloudWatch Scala JDK
1.0.0 1.0.0 2.10,2.11,2.12 1.8+
2.0.0 1.1.x 2.11,2.12,2.13 1.8+

Getting Started

Add library dependency to your build.sbt

libraryDependencies += "com.github.alonsodomin" %% "kamon-cloudwatch" % "<version>"

The module will be loaded automatically and you should see "Starting the Kamon CloudWatch extension" message in your logs output.

Note: Be sure the box in which this is going to be used, has the proper access credentials to send data to AWS CloudWatch. The preferred approach would be to either use an InstanceProfile or roles in the case of ECS/Docker Containers. Another way would be to have the environment variables AWS_ACCESS_KEY_ID and AWS_SECRET_ACCESS_KEY set correctly.

Kamon 1.0 users

If using Kamon 1.x, you will need to register it manually during application startup:

val reporter = new CloudWatchReporter()
Kamon.addReporter(reporter)

Configuration

You can configure the module behaviour by overriding any of the following settings in your application.conf file:

kamon {
  cloudwatch {

    # namespace is the AWS Metrics custom namespace
    namespace = <application name>
    
    # (Optional) AWS region, on ec2 region is fetched by getCurrentRegion command
    region = eu-west-1

    # batch size of data when send to Cloudwatch. Default: 20
    batch-size = 20

    # how many threads will be assigned to the pool that does the shipment of metrics. Default: 5
    async-threads = 5
    
    # whether to add Kamon environment tags to each of the metrics. Default: false
    include-environment-tags = false

    # explicit aws access key and secret definition (optional)
    # if not specified values fetched from one of the followings
    #   * AWS_PROFILE env variable
    #   * AWS_ACCESS_KEY_ID and AWS_SECRET_ACCESS_KEY env variables
    #   * Amazon EC2 Instance Metadata
    # access-key-id = ""
    # secret-access-key = ""

  }
}

AWS Cloudwatch Example

  • log on to Cloudwatch, the metrics will be appearing on 'Custom namespaces' section under "Metrics" menu, i.e.: alt text

License