Expand my Community achievements bar.

Don’t miss the AEM Skill Exchange in SF on Nov 14—hear from industry leaders, learn best practices, and enhance your AEM strategy with practical tips.
SOLVED

AEM + Prometheus JMX Exporter

Avatar

Level 2

Does anyone have experience integrating AEM with Prometheus JMX Exporter (GitHub - prometheus/jmx_exporter: A process for exposing JMX Beans via HTTP for Prometheus consumpti...

I am trying to setup a monitoring/alerting system in place for some of the key metrics such as replication queues etc.

1 Accepted Solution

Avatar

Correct answer by
Level 4

Yes I do. Quite easy actually. Just use the java agent and put the required java startup parameters in your CQ_JVM_OPTS environment variable before starting AEM.

Be be sure to whitelist only the beans you need. By default all JMX beans are monitored and in AEM that is quite a lot.

View solution in original post

7 Replies

Avatar

Correct answer by
Level 4

Yes I do. Quite easy actually. Just use the java agent and put the required java startup parameters in your CQ_JVM_OPTS environment variable before starting AEM.

Be be sure to whitelist only the beans you need. By default all JMX beans are monitored and in AEM that is quite a lot.

Avatar

Level 1

I have been trying to get this too work with the jmx_prometheus_httpserver-0.3.1-jar-with-dependencies.jar jar file, but it trows a bunch of errors in the logs.

*WARN* [RMI TCP Connection(175)-<IP Address>] org.apache.jackrabbit.oak.jcr.session.RefreshStrategy This session has been idle for 4 minutes and might be out of date. Consider using a fresh session or explicitly refresh the session.

java.lang.Exception: The session was created here:

Do you know why this is happening?  Can you provide a sample on how to use the java agent with AEM?

Avatar

Level 4

Some JMX beans in AEM don't properly close their JCR session, which causes the errors you see.

I opened some Daycare issues to report that.

Best is to whitelist only the JMX beans you want to extract data from (depends on your monitoring needs).

Download the prometheus Java agent jar as described on GitHub - prometheus/jmx_exporter: A process for exposing JMX Beans via HTTP for Prometheus consumpt... and copy it into /usr/local/bin/jmx_prometheus_javaagent.jar

Edit the file crx-quickstart/bin/start-env and add following line:

JVM_OPTS='-javaagent:/usr/local/bin/jmx_prometheus_javaagent.jar=9242:/etc/prometheus/jmx-exporter-config.yaml'

Create the file /etc/prometheus/jmx-exporter-config.yaml and give it (for example) following content:

whitelistObjectNames: [

  "com.adobe.granite:type=Repository",

  "com.adobe.granite.replication:type=agent,*",

  "java.lang:*",

  "org.apache.jackrabbit.oak:type=\"Standby\",*",

  "org.apache.jackrabbit.oak:type=SegmentRevisionGarbageCollection,*",

  "org.apache.jackrabbit.oak:type=Metrics,name=SESSION_COUNT",

  "org.apache.jackrabbit.oak:type=IndexStats,name=async",

  "org.apache.sling:type=queues,*",

  "org.apache.sling.installer:type=Installer,name=Sling OSGi Installer",

]

Finally start AEM as follows:

crx-quickstart/bin/start

The prometheus exporter will be running at http://localhost:9242/metrics.

Avatar

Level 1

I have tried the above one with multiple configurations but getting the following error

 

no main manifest attribute, in /app/jmx_prometheus_javaagent-0.16.1.jar

Avatar

Level 1

This worked.  Thanks!  One thing I have noticed about the JMX Exporter does add to the CPU.  if you change it to scrape every 60 - 90 seconds it only adds 4% - 5% to the CPU. 

Avatar

Level 1

Thanks for posting this question and answer. This worked well, but I needed to remove the \"Quotes\" around the Standby type (using JMX Exporter 0.5).

For me it didn't seem to add anything to the CPU, even at 5sec polling. 1sec poll added a couple of percent. Perhaps the new version is more performant.