1

When I run scala application using 'sbt run' command it is sending kamon metrics to graphite/grafana container. Then I created a docker image for my scala application and running it as a docker container. Now it is not sending metrics to graphite/grafana container. Both my application container and graphite/grafana container are running under same docker network.

The command I used to run grafana image is: docker run --network smart -d -p 80:80 -p 81:81 -p 2003:2003 -p 8125:8125/udp -p 8126:8126 8399049ce731

kamon configuration in application.conf is

  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
    }
 }

your help will be very much appreciated.

Alex Riabov
  • 8,655
  • 5
  • 47
  • 48
Praveen
  • 21
  • 3

1 Answers1

0

It is necessary to add AspectJ weaver as Java Agent when you're starting application: -javaagent:aspectjweaver.jar

You can add the following settings in your project SBT configuration:

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

So AspectJ weaver JAR will be copied to ./lib_managed/jars/org.aspectj/aspectjweaver/aspectjweaver-[aspectJWeaverV].jar in your project root.

Then you can refer this JAR in your Dockerfile:

COPY ./lib_managed/jars/org.aspectj/aspectjweaver/aspectjweaver-*.jar /app- 
workdir/aspectjweaver.jar
WORKDIR /app-workdir
CMD ["java", "-javaagent:aspectjweaver.jar", "-jar", "app.jar"]
Alex Elkin
  • 574
  • 6
  • 11