AEM: Integrate Graphite Metrics

Espacially when you have larger services running in your Adobe Experience Manager an metrics database can become quite handy (for both developers and the customer).

We decided to use Graphite as database and visualize the data with Grafana.

Integration in your project

The wcm.io Caravan project provides a Maven Module you can use in your project.

io.wcm.caravan io.wcm.caravan.commons.metrics 0.6.0 Depending on your project, you might need to include the Dropwizard Metrics Libraries.

Configuration

After deploying the packages, you’ll find a new Configuration in your OSGi console.

wcm.io Caravan Resilient Http Graphite Integration Configuration

Usage

You can now inject the MetricRegistry into your components and use it as described in Dropwizard’s Manual

@Reference
private MetricRegistry metricRegistry;

public void someThingWithTimer() {
Context timer = metricRegistry.timer(“myTimerName”).time();
// Do some stuff…

timer.close();
}

Note: Although this post describes how to use Graphite in AEM, it’s also no problem to use this for a plain OSGi project.