Samza REST supports the ability to add Monitors to the service. Monitors are essentially tasks that can be scheduled to run periodically. It provides the capability to the users to define configurations that are specific to individual Monitors. These configurations are injected into the monitor instances through the Config instances.

Monitor configuration

All of the configuration keys for the monitors should be prefixed with monitor.{monitorName}. Since each monitor is expected to have an unique name, these prefixes provide the namespacing across the monitor configurations.

The following configurations are required for each of the monitors.

Name Default Description This defines the periodic scheduling interval in milliseconds for a monitor named monitorName. If this configuration is not defined, it is defaulted to 60 seconds.
monitor.monitorName.factory.class Required: This should contain a fully qualified name of a class that implements the MonitorFactory interface. Monitors that are instantiated by the factory implementation will be scheduled for periodic execution. Custom implementations of the MonitorFactory interface are expected to inject the Config and MetricsRegistry instances available in the createMonitor method into the Monitors.

For example, configurations for two monitors named NMTaskMonitor and RMTaskMonitor should be defined as follows.





Implementing a New Monitor

Implement the Monitor interface with some behavior that should be executed periodically. The Monitor is Java code that invokes some method on the SAMZA Rest Service, runs a bash script to restart a failed NodeManager, or cleans old RocksDB sst files left by Host Affinity, for example.

Implement the MonitorFactory interface, which will be used to instantiate your Monitor. Each Monitor implementation should have a associated MonitorFactory implementation, which is responsible for instantiating the monitors.

Adding a New Monitor to the Samza REST Service

Add the fully-qualified class name of the MonitorFactory implementation to the monitor.monitorName.factory.class property in the service config. Set the config key to the scheduling interval in milliseconds.

The configuration key defines the periodic scheduling interval of the monitor() method in milli seconds.

Reporting metrics from Monitors

Samza REST service allows the users to create and report metrics from their monitors. Reporting metrics to a metrics system is encapsulated by the metrics reporter, which should be defined in the samza-rest configuration file. Configurations for metrics reporters in Samza REST service are the same as that of Samza Jobs.

Resource Reference »