Metrics
The process engine reports runtime metrics to the database that can help draw conclusions about usage, load, and performance of the BPM platform. Metrics are reported in the database table ACT_RU_METER_LOG
as natural numbers in the Java long
range and count the occurrence of specific events. Single metric entries consist of a metric identifier, a value that the metric took in a certain timespan and a name identifying the metric reporter. There is a set of built-in metrics that are reported by default.
Built-in Metrics
The following table describes the built-in metrics. The identifiers of all built-in metrics are available as constants of the class org.camunda.bpm.engine.management.Metrics .
Category | Identifier | Description |
---|---|---|
BPMN Execution | activity-instance-start | The number of activity instances started. This is also known as flow node instances (FNI). |
activity-instance-end/td> | The number of activity instances ended. | |
DMN Execution | executed-decision-elements | The number of decision elements executed during evaluation of DMN decision tables. For one table, this is calculated as the number of clauses multiplied by the number of rules. |
Job Executor | job-successful | The number of jobs successfully executed. |
job-failed | The number of jobs that failed to execute and that were submitted for retry. Every failed attempt to execute a job is counted. | |
job-acquisition-attempt | The number of job acquisition cycles performed. | |
job-acquired-success | The number of jobs that were acquired and successfully locked for execution. | |
job-acquired-failure | The number of jobs that were acquired but could not be locked for execution due to another job executor locking/executing the jobs in parallel. | |
job-execution-rejected | The number of successfully acquired jobs submitted for execution that were rejected due to saturated execution resources. This is an indicator that the execution thread pool's job queue is full. | |
job-locked-exclusive | The number of exclusive jobs that are immediately locked and executed. | |
History Clean up | history-cleanup-removed-process-instances | The number of process instances removed by history clean up. |
history-cleanup-removed-case-instances | The number of case instances removed by history clean up. | |
history-cleanup-removed-decision-instances | The number of decision instances removed by history clean up. | |
history-cleanup-removed-batch-operations | The number of batch operations removed by history clean up. |
Querying
Metrics can be queried by making a MetricsQuery
offered by the ManagementService
. For example, the following query retrieves the number of all executed activity instances throughout the entire history of reporting:
long numCompletedActivityInstances = managementService
.createMetricsQuery()
.name(Metrics.ACTIVTY_INSTANCE_START)
.sum();
The metrics query offers filters #startDate(Date date)
and #endDate(Date date)
to restrict the collected metrics to a certain timespan. In addition, by using the filter #reporter(String reporterId)
the results can be restricted to metrics collected by a specific reporter. This option can be useful when configuring more than one engine against the same database, for example in a cluster setup.
Configuration
Metrics Reporter
The process engine flushes the collected metrics to the runtime database tables in an interval of 15 minutes. The behavior of metrics reporting can be changed by replacing the dbMetricsReporter
instance of the process engine configuration. For example, to change the reporting interval, a process engine plugin replacing the reporter can be employed:
public class MetricsConfigurationPlugin implements ProcessEnginePlugin {
public void preInit(ProcessEngineConfigurationImpl processEngineConfiguration) {
}
public void postInit(ProcessEngineConfigurationImpl processEngineConfiguration) {
DbMetricsReporter metricsReporter = new DbMetricsReporter(processEngineConfiguration.getMetricsRegistry(),
processEngineConfiguration.getCommandExecutorTxRequired());
metricsReporter.setReportingIntervalInSeconds(5);
processEngineConfiguration.setDbMetricsReporter(metricsReporter);
}
public void postProcessEngineBuild(ProcessEngine processEngine) {
}
}
Reporter Identifier
Metrics are reported with an identifier of the reporting party. This identifier allows to attribute reports to individual engine instances when making a metrics query. For example in a cluster, load metrics can be related to individual cluster nodes. By default the process engine generates a reporter id as <local IP>$<engine name>
. The generation can be customized by implementing the interface org.camunda.bpm.engine.impl.metrics.MetricsReporterIdProvider
and setting the engine property metricsReporterIdProvider
to an instance of that class.
Disable Reporting
By default, all built-in metrics are reported. For the configuration via XML file (e.g. standalone.xml or bpm-platform.xml) you can disable reporting by adding the property:
<property name="metricsEnabled">false</property>
If you are directly accessing the Java API, you can disable the metrics reporting by using the engine configuration flag isMetricsEnabled
and set it to false
.