gpt4 book ai didi

scala - 当我将 scala 应用程序作为 docker 容器运行时,kamon statsd 不发送指标

转载 作者:行者123 更新时间:2023-12-02 20:04:09 27 4
gpt4 key购买 nike

当我使用 'sbt run' 运行 scala 应用程序时命令它将 kamon 指标发送到 Graphite /grafana 容器。然后我为我的 scala 应用程序创建了一个 docker 镜像并将其作为 docker 容器运行。
现在它不会将指标发送到 Graphite /grafana 容器。我的应用程序容器和 Graphite /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
}
}

您的帮助将不胜感激。

最佳答案

有必要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"]

关于scala - 当我将 scala 应用程序作为 docker 容器运行时,kamon statsd 不发送指标,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/51184596/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com