jmxremote configuration for cadahale-metrics

classic Classic list List threaded Threaded
5 messages Options
Reply | Threaded
Open this post in threaded view
|

jmxremote configuration for cadahale-metrics

zedar185
I run ratpack with ./gradlew run - groovy wrapper with codahale metrics over jmx.
Is it possible to pass properties for jmxremote configuration directly to jvm instance running GroovyRatpackMain class?

Once added cadahale-metrics module, configu red in Ratpack.groovy:

  bindings {
    add new CodaHaleMetricsModule().metrics().jvmMetrics().healthChecks().jmx()
  }

metrics are only available when connecting (via jconsole) to local jvm process running ratpack.groovy.launch.GroovyRatpackMain.

To access remote jmx server it is neccessary to pass some properties to jvm:
-Dcom.sun.management.jmxremote
-Dcom.sun.management.jmxremote.port=5999
-Dcom.sun.management.jmxremote.local.only=false
-Dcom.sun.management.jmxremote.authenticate=false
-Dcom.sun.management.jmxremote.ssl=false
-Dcom.sun.management.jmxremote.rmi.port=5998

If I add them to DEFAULT_JVM_OPTS variable (in gradlew script) thay apply only to Groovy Wrapper process (process running org.gradle.wrapper.GradleWrapperMain).
They are not passed to GroovyRatpackMain process.

Is there anything like ratpack.port configuration for such purposes:

run {
  jvmArgs "-Dratpack.port=8080"
}
Reply | Threaded
Open this post in threaded view
|

Re: jmxremote configuration for cadahale-metrics

Luke Daley
Administrator
Hi,

There are two processes involved here, the Gradle build process and the Ratpack application process. The environment in which you launch Gradle only affects the former.

To set these for the Ratpack process you need to configure it in the build:

run {
  jvmArgs "-Dcom.sun.management.jmxremote.port=5999”
  …
}
Reply | Threaded
Open this post in threaded view
|

Re: jmxremote configuration for cadahale-metrics

uris77
In reply to this post by zedar185
I create a file (.env in my case) where I put those variables and then load them up inside the run tasks. Here is an example https://github.com/uris77/got-get-campaigns/blob/master/build.gradle#L86
Reply | Threaded
Open this post in threaded view
|

Re: jmxremote configuration for cadahale-metrics

zedar185
In reply to this post by Luke Daley
Luke, try jvmArgs option with more than one setting. For example:

run {
  jvmArgs "-Dcom.sun.management.jmxremote.port=5999 -Dcom.sun.management.jmxremote.local.only=false -Dcom.sun.management.jmxremote.authenticate=false -Dcom.sun.management.jmxremote.ssl=false -Dcom.sun.management.jmxremote.rmi.port=5998"
}

and you will get an error:

Error: Invalid com.sun.management.jmxremote.port number: 5999 -Dcom.sun.management.jmxremote.local.only=false -Dcom.sun.management.jmxremote.authenticate=false -Dcom.sun.management.jmxremote.ssl=false -Dcom.sun.management.jmxremote.rmi.port=5998
:run FAILED
Reply | Threaded
Open this post in threaded view
|

Re: jmxremote configuration for cadahale-metrics

zedar185
This configuration works:

run {
  jvmArgs "-Dcom.sun.management.jmxremote.port=5999"
  jvmArgs "-Dcom.sun.management.jmxremote.local.only=false"
  jvmArgs "-Dcom.sun.management.jmxremote.authenticate=false"
  jvmArgs "-Dcom.sun.management.jmxremote.ssl=false"
  jvmArgs "-Dcom.sun.management.jmxremote.rmi.port=5998"
}

and reading properties from configuration file in run task works too.

Thanks for your help.