Chapter 27. Monitoring Nuxeo

Table of Contents

27.1. Integrating Nuxeo monitoring in your management system
27.1.1. Inventory (nx:*,management=inventory)
27.1.2. Metric (nx:*,metric=*,management=metric)
27.1.3. Quality (nx:*,usecase=*,management=usecase)
27.2. Integrating management in nuxeo server
27.2.1. nuxeo-runtime-management
27.2.2. nuxeo-platform-management
27.2.3. nuxeo-webengine-management
27.3. Contributing management
27.3.1. Publishing
27.3.2. Providing shortcuts
27.3.3. Reporting quality

Nuxeo comes with management by providing a resource publisher, an use case scheduler and a REST XML serializer. Nuxeo makes use of theses services for providing you information about components deployment, directory status, events metric, http and directories session metrics.

These services is to used for integrating nuxeo in a management platform.

27.1. Integrating Nuxeo monitoring in your management system

As an administrator, I want to monitor my Nuxeo server.

Nuxeo exposes monitoring data and behaviors by using the JMX standard. If your management platform does not support JMX, you're able to feed it using the XML serializer provided as a WebEngine module. Nuxeo provided mbeans are published in the "nx" domain.

Nuxeo has identified these kinds of monitoring data : inventory, metric and usecase. Nuxeo types theses objects using the "management naming attribute.

27.1.1. Inventory (nx:*,management=inventory)

The inventory is based onto the component registry. It mainly adapt the registration objects graph (components, extension points, contributions) as an mbean tree. This gives you an access to what and how are the services deployed. Other informations about these services (metrics, status, usecases) will be is to be attached to the inventory. Using these information, you can check that your server is correctly deployed.

27.1.2. Metric (nx:*,metric=*,management=metric)

Inventory is being completed by metrics. It's the accounting information that they can easily provide to users with no costs overhead. As example, directory manager provide core sessions counters. These information are bound into the mbeans tree. Managers defines gauges that polls metric for treesholds or to gather historical data.

27.1.3. Quality (nx:*,usecase=*,management=usecase)

Services are tested periodically by running a typical use case. Results about are published in the service subtree by the management use case scheduler. These informations is to be polled by managers for issuing alerts. We already defined a use case checking that the repository is well working by creating and removing a document.

27.2. Integrating management in nuxeo server

As an administrator, I want to enable nuxeo platform management features.

Management is packaged into three distinct packages : nuxeo-runtime-management, nuxeo-platform-management and nuxeo-webengine-management modules.

27.2.1. nuxeo-runtime-management

That module contains the management logic : the resource publisher and the use cases scheduelr. These services implements only behaviours and have to be contributed by other components for activation.

27.2.2. nuxeo-platform-management

That module contains adapters for nuxeo services such as the runtime inventory or the http session metric. It also contains the use case scheduler and some typical use cases such as the directory one.

Nuxeo platform management provides you the basic monitoring resources. The following section describes how coding integrating newer monitoring resources suitable for your needs.

27.2.3. nuxeo-webengine-management

That module contains a web engine module for serializing in XML mbeans. You have to use it if your management platform is not JMX aware.

27.3. Contributing management

27.3.1. Publishing

As a developper, I want to publish some informations suitable for monitoring services I'm in charge for.

Here is the typical use cases for : service publishing, resource publishing and mbeans aliasing.

27.3.1.1. Publishing a service

As a developer, I want to publish a service. Usually, services are defined as singleton.

To publish summarized informations about this service, you first have to define a Java interface for and makes your singleton implementing it. Then, you have to contribute to the resource publisher service, naming your singleton. Given the monitoring interface myPackage.MyServiceMBean and the implemented class myPackage.MyService , you have to define an extension in service definition as follow :

                      ..
          <require>org.nuxeo.runtime.management.ResourcePublisher</require>
          <extension point="services"
            target="org.nuxeo.runtime.management.ResourcePublisher">
            <service class="mypackage.MyService"
              ifClass="myPackage.MyServiceMBean" name="myService" />
          </extension>
          ..
          

Note

As you respect a JMX convention, resource publisher is able to guess the interface class you use by its name. So, in that case, it is not mandatory to provide the interface class name.

27.3.1.2. Publishing resources using a factory

As a developer, I want to publish a collection of informations, such as a map of metrics.

The first idea is to expose a getter that returns the map. That kind of information is not well supported on manager side. Monitors and gauges are just able to bind to attribute with a string or numeric type. If the cardinality is acceptable, the resource publisher enables you to register a factory that is to be call backed for publishing your resources. Given the monitoring interface MyMetricMBean , the MyMetricFactory will publish metrics provided by MyService

            package mypackage;

import org.nuxeo.runtime.management.ResourceFactory;
import org.nuxeo.runtime.management.ObjectNameFactory;

public class MyMetricFactory implements ResourceFactory {

  public void configure(ResourcePublisherService publisher, ResourceFactoryDescriptor descriptor) {
    this.publisher = publisher;
    this.service = (MyService)Framework.getLocalService(My.class);
  }

  protected final ComponentName myServiceName = MyService:NAME;

  protected MyService service;
  protected ResourcePublisher publisher;

  public void registerResources() {
    for (String name:myService.doGetMetricNames() {
      doRegisterMetric(name);
    }
  }

  protected void doRegisterMetric(String name) {
    MyMetricContext context = new MyMetricContext(String name, service);
    String shortName = ObjectNameFactorty.formatMetricShortName(name);
    ObjectName qualifiedName = ObjectNameFactory.formatMetricQualifiedName(myServiceName,name);
    publisher.registerResource(shortName, qualifiedName, MyMetricMBean.class, metric);
  }

}
          

            package mypackage;


public class MyMetricContext implements MyMetricMBean {

  public void MyMetricContext(String name, MyService service) {
    this.service = service;
    this.name = name;
  }
 
  protected final String name;
  protected final MyService service;
     
  int getCount() {
    return service.doGetCount(name);
  }


}
          

            package mypackage;


public class MyService implements Service {

   protected String doGetNames() {
     ..
     return ...
   }

   protected int doGetCount(String name) {
     ..
     return ...
   }
}
          

                      ..
          <require>org.nuxeo.runtime.management.ResourcePublisher</require>
          <extension point="factories"
            target="org.nuxeo.runtime.management.ResourcePublisher">
            <factory class="mypackage.MyMetricFactory"
              ifClass="myPackage.MyMetricMBean" name="myMetricFactory" />
          </extension>
          ..
          

27.3.2. Providing shortcuts

As an administrator I want to monitor OperatingSystem attributes in my management system using the XML serializer. I will contribute to the resource publisher by defining the following extension point :

                    ..
          <require>org.nuxeo.runtime.management.ResourcePublisher</require>
          <extension point="shortcuts"
            target="org.nuxeo.runtime.management.ResourcePublisher">
            ..
            <shortcut name="operatingSystem" qualifiedName="java.lang:type=OperatingSystem"/>
            ..
          </extension>
          ..
        

27.3.3. Reporting quality

As a developer, I want to provide a feature operational status.

Services quality are to be monitored by scheduling typical use cases. Use cases should throw an exception for indicating error condition. Use cases are registered under the service they belongs to.

                    ..
          <require>org.nuxeo.ecm.management.usecases.UsecaseScheduler</require>
          <extension point="usecases"
            target="org.nuxeo.runtime.management.ResourcePublisher">
            <usecase name="myUsecase" class="mypackage.MyUsecase"
              serviceClass="mypackage.My" />
          </extension>
          ..
        

          package mypackage;

import org.nuxeo.ecm.management.usecases.Usecase;

public class MyUsecase implements Usecase {

   void init(Object service) {
     this.service = (My)service;
   }
   
   MyService service;
   
   void runCase(CoreSession session) throws ClientException {
      service.doSomething();
   }

}