Skip to content

A tiny scala wrapper around AWS CloudWatch Java client.

License

Notifications You must be signed in to change notification settings

mkotsur/gfc-aws-cloudwatch

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

61 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

gfc-aws-cloudwatch Join the chat at https://gitter.im/gilt/gfc

A thin Scala wrapper around AWS CloudWatch Java client. Part of the Gilt Foundation Classes.

Getting gfc-aws-cloudwatch

The latest version is 1.1.6, which is cross-built against Scala 2.11.x and 2.12.x

Add dependency to build.sbt:

libraryDependencies += "com.gilt" %% "gfc-aws-cloudwatch" % "1.1.6"

Basic usage

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

  val SubServiceMetricBuilder = {
    CloudWatchMetricDataAggregator.builder.withMetricNamespace("TopLevelNamespace")
  }

  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()

..........

  SuccessfulCreateFoo.increment()
  SuccessfulUpdateFoo.increment()
  .....

Quick example:

implicit
object FooMetricToCloudWatchMetricsData
  extends ToCloudWatchMetricsData[Foo] {

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

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

CloudWatchMetricsClient("TopLevelNamespace").
  enterNamespace("foo"). // optionally enter more specific namespace
  putMetricData(someFoo)


implicit
object FooMetricToCloudWatchLogsData
  extends ToCloudWatchLogsData[Foo] {

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

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

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

License

Copyright 2017 Gilt Groupe, Inc.

Licensed under the Apache License, Version 2.0: http://www.apache.org/licenses/LICENSE-2.0

About

A tiny scala wrapper around AWS CloudWatch Java client.

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Contributors 3

  •  
  •  
  •  

Languages