James relies on the Dropwizard metric library for keeping track of some core metrics of James.
Such metrics are made available via JMX. You can connect for instance using VisualVM and the associated mbean plugins.
James come with native integration to the prometheus eco-system. Read below.
You can also export the metrics to ElasticSearch and visualize them with Grafana.
See elaticseach.properties documentation for more details on how to set this up.
WARNING: Supported ElasticSearch versions for metrics differs from the James one. Only ElasticSearch version 2 to 6 are supported. This requires a distinct ElasticSearch isntalation for metrics.
This component is furthermore unmaintained an use is discouraged.
Yet another solution is to have metrics values written in logs, see See Monitor via Logging.
To enable James metrics, add extensions.routes
to webadmin.properties file:
extensions.routes=org.apache.james.webadmin.dropwizard.MetricsRoutes
Connect to james-admin url to test the result:
http://james-admin-url/metrics
Here are the available metrics :
In addition to these metrics, you can define your own metrics using the Metrics mailet. By adding it in your mailet container, you can count emails that pass via any points. You can also, using matchers, count emails that matches the conditions you defined.
Those metrics are only available with Guice.