如何配置Kamon for dockerized Akka应用程序?

时间:2018-05-22 13:21:45

标签: akka datadog kamon akka-monitoring

我在Akka中创建了一个用于测试Kamon + DataDog监控的示例服务。

以下是我添加的依赖项:

"io.kamon" %% "kamon-core" % "1.1.0",
"io.kamon" %% "kamon-datadog" % "1.0.0",
"io.kamon" %% "kamon-akka-2.5" % "1.0.1"

以下是build.sbt中启用的插件:

.enablePlugins(AshScriptPlugin, DockerPlugin, SbtAspectJRunner)

然后application.conf

kamon {
  datadog {
    time-units = "ms"
    memory-units = "b"
  }
  util {
    filters {
      "akka.tracked-actor" {
        includes = [ "testSystem/user/**" ]
        excludes = [ "testSystem/system/**" ]
      }

      "s3-worker-actors" {
        includes = [ "testSystem/user/s3Router/*" ]
      }

      "fb-worker-actors" {
        includes = [ "testSystem/user/fbRouter/*" ]
      }

      "akka.tracked-router" {
        includes = [ "testSystem/user/s3Router", "testSystem/user/fbRouter" ]
      }

      "akka.tracked-dispatcher" {
        includes = [ "**" ]
      }

      "akka.traced-actor" {
        includes = [ "**" ]
      }
    }
  }
  akka.actor-groups = [ "s3-worker-actors", "fb-worker-actors" ]
}

最后在我调用的Main类中:

Kamon.addReporter(new DatadogAgentReporter())

在EC2上,我为docker安装了datadog-agent。

当我在EC2实例上运行服务容器然后查看DataDog界面时,我没有看到任何与akka相关的指标,只是一个标准指标列表,如:datadog.process.agent,{{1 },docker.cpu.usage

如果将akka应用程序打包到docker并部署在EC2上,如何启用与akka相关的指标?

1 个答案:

答案 0 :(得分:0)

开始进行Akka复制时,必须add AspectJ weaver as Java Agent-javaagent:aspectjweaver.jar

您可以在项目SBT配置中添加以下设置:

.settings(
  retrieveManaged := true,
  libraryDependencies += "org.aspectj" % "aspectjweaver" % aspectJWeaverV)

因此,AspectJ weaver JAR将被复制到项目根目录中的./lib_managed/jars/org.aspectj/aspectjweaver/aspectjweaver-[aspectJWeaverV].jar

然后您可以在Dockerfile中引用此JAR:

COPY ./lib_managed/jars/org.aspectj/aspectjweaver/aspectjweaver-*.jar /app- 
workdir/aspectjweaver.jar
WORKDIR /app-workdir
CMD ["java", "-javaagent:aspectjweaver.jar", "-jar", "app.jar"]