gfc-collective / gfc-aws-cloudwatch   2.0.0

Apache License 2.0 GitHub

A tiny Scala wrapper around AWS CloudWatch Java client.

Scala versions: 2.13 2.12

gfc-aws-cloudwatch Maven Central Build Status Coverage Status

A thin Scala wrapper around AWS CloudWatch Java client. A fork and new home of the now unmaintained Gilt Foundation Classes (com.gilt.gfc), now called the GFC Collective, maintained by some of the original authors.

Getting gfc-aws-cloudwatch

The latest version of gfc-aws-cloudwatch using the AWS 1.x libraries is 1.4.1 (maintained on the 1.x branch), The latest version of gfc-aws-cloudwatch using the AWS 2.x libraries is 2.0.0 (maintained on the main branch). Both versions are cross-compiled against Scala 2.12.x and 2.13.x and were released on 21/Jan/2020.

If you're using SBT, add the following line to your build file:

libraryDependencies += "org.gfccollective" %% "gfc-aws-cloudwatch" % "2.0.0"

For Maven and other build tools, you can visit (This search will also list other available libraries from the GFC Collective.)

Basic usage

Quick metric aggregator example (less flexible than CW APIs but can save costs when you have high-frequency events):

  val cwPublisher = CloudWatchMetricsPublisher.start(1 minute)

  val SubServiceMetricBuilder = {

  val Count = SubServiceMetricBuilder.withUnit(StandardUnit.Count)

  val SuccessCount = Count.withMetricName("success")

  def kind = new Dimension().withName("kind")

  val SuccessfulCreate = SuccessCount.addDimensions(kind.withValue("create"))

  val SuccessfulUpdate = SuccessCount.addDimensions(kind.withValue("update"))

  val SuccessfulCreateFoo = SuccessfulCreate.enterMetricNamespace("foo").start()
  val SuccessfulUpdateFoo = SuccessfulUpdate.enterMetricNamespace("foo").start()

  val SuccessfulCreateBar = SuccessfulCreate.enterMetricNamespace("bar").start()
  val SuccessfulUpdateBar = SuccessfulUpdate.enterMetricNamespace("bar").start()



Quick example:

object FooMetricToCloudWatchMetricsData
  extends ToCloudWatchMetricsData[Foo] {

  def toMetricData( t: Foo
                  ): Seq[MetricDatum] = {
    // convert to metric data

// ..........

  enterNamespace("foo"). // optionally enter more specific namespace

object FooMetricToCloudWatchLogsData
  extends ToCloudWatchLogsData[Foo] {

  def toLogEvents( t: Foo
                  ): Seq[InputLogEvent] = {
    // convert to log events

// ..........

  enterNamespace("foo"). // optionally enter more specific namespace
  putLogData("streamName", someFoo)


Licensed under the Apache License, Version 2.0: