Skip to main content
Metrics let you show users how a roster is developing while the solver runs. Each metric is an aggregate for the current roster. The returned scope matches the scope you requested, which makes it straightforward to associate a value with the metric shown in your user interface.
A metric value is null until the solver publishes its first metrics update, or when the selected scope has no value.

Scope metrics with rule labels

A metric scope is defined by its metricKey and, optionally, its ruleLabel:
ruleLabel can only be used for metrics based on labeled rules.
  • With only a metricKey, the service aggregates that metric across every rule of the relevant type.
  • With both a metricKey and ruleLabel, it aggregates only rules of that type that have the exact, case-sensitive label.
This lets you track a meaningful business measure rather than every instance of a rule type. For example, label each Period Distribution rule that limits weekend work with maximum-weekend-amount, then request PERIOD_DISTRIBUTION.EXCESSIVE_WORKED_PERIODS with that label. The result is the total number of excessive weekend periods across all matching rules.
Track excessive weekend periods

Track and show metrics

1

Choose the metrics to track

Add each metric scope to statusOptions.metricScopes in your POST /roster/start request. A scope can track a metric across all matching rules, or use ruleLabel to limit it to a labeled group of rules.
Add status options to the roster start request
2

Start the roster job

Send the roster start request and retain the returned jobId. The service creates one status-metric entry for every requested scope.
3

Poll the job status

Call GET /roster/status/{jobId} while the job runs. Each response contains the latest values in the metrics array, using the same scopes you requested.
Metrics returned when checking job status
4

Show progress to users

Match every returned scope to the metric in your interface and update its displayed value on each poll. Values will move as the solver improves the roster.

Available metrics