1

当我使用命令运行 scala 应用程序时,'sbt run'它会将 kamon 指标发送到石墨/grafana 容器。然后我为我的 scala 应用程序创建了一个 docker 映像并将其作为 docker 容器运行。现在它不会将指标发送到石墨/grafana 容器。我的应用程序容器和石墨/grafana 容器都在同一个 docker 网络下运行。

我用来运行 grafana 映像的命令是:docker run --network smart -d -p 80:80 -p 81:81 -p 2003:2003 -p 8125:8125/udp -p 8126:8126 8399049ce731

application.conf 中的 kamon 配置是

  kamon {
     auto-start=true
     metric {
       tick-interval = 1 seconds
         filters {
           akka-actor {
              includes = ["*/user/*"]
              excludes = [ "*/system/**", "*/user/IO-**", "**/kamon/**" ]      
           }
           akka-router {
              includes = ["*/user/*"]
              excludes = [ "*/system/**", "*/user/IO-**", "**/kamon/**" ]      
           }
           akka-dispatcher {
              includes = ["*/user/*"]
              excludes = [ "*/system/**", "*/user/IO-**", "*kamon*", 
                  "*/kamon/*", "**/kamon/**" ]
           }
           trace {
              includes = [ "**" ]
              excludes = [ ]enter code here
            }
         }
   }

    # needed for "[error] Exception in thread "main" 
    java.lang.ClassNotFoundException: local"
     internal-config {
       akka.actor.provider = "akka.actor.LocalActorRefProvider"
     }

    statsd {
      hostname = "127.0.0.1"
      port = 8125
      # Subscription patterns used to select which metrics will be pushed 
      to StatsD. Note that first, metrics
      # collection for your desired entities must be activated under the 
      kamon.metrics.filters settings.
      subscriptions {
         histogram       = [ "**" ]
         min-max-counter = [ "**" ]
         gauge           = [ "**" ]
         counter         = [ "**" ]
         trace           = [ "**" ]
         trace-segment   = [ "**" ]
         akka-actor      = [ "**" ]
         akka-dispatcher = [ "**" ]
         akka-router     = [ "**" ]
         system-metric   = [ "**" ]
         http-server     = [ "**" ]
      }
     metric-key-generator = kamon.statsd.SimpleMetricKeyGenerator
     simple-metric-key-generator {
        application = "my-application"
        include-hostname = true
        hostname-override = none
        metric-name-normalization-strategy = normalize
     }
   }

    modules {
      kamon-scala.auto-start = yes
      kamon-statsd.auto-start = yes
      kamon-system-metrics.auto-start = yes
    }
 }

您的帮助将不胜感激。

4

1 回答 1

0

启动应用程序时,需要将 AspectJ weaver 添加为 Java 代理:-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"]
于 2018-10-24T14:02:03.477 回答