CORAL WIKI

StatsActor

The StatsActor (statistics actor) is a Coral Actor that gathers a single real valued measurement from a stream of events. It saves a number of statistics as state.

Creating a StatsActor

The creation JSON of the stats actor (see Coral Actor) has "type": "stats". The params value is a JSON with a single field:

field type required description
field string yes the name of the field in the trigger-JSON to monitor

Example

{
  "data": {
    "type": "actors",
    "attributes": {
      "type": "stats",
      "params": {
        "field": "amount"
      },
      "group": {
        "by": "tag"
      }
    }
  }
}

This will create a statistics component monitoring the field amount. Each different value for the field tag will have a separate state.

Trigger

The StatsActor only does useful work if the trigger is connected. The actor gathers values supplied by the field specified in the parameters.

Emit

The StatsActor emits nothing. Only the state provides information.

State

The StatsActor keeps the following summary statistics as state:

field type description
count integer number of values processed
avg float the average value
sd float the (population) standard deviation
min float the minimum value
max float the maximum value

The state is updated every time a value for the specified field is encountered in the trigger. Note that when no events have occurred the count is zero, and other fields are undefined. This is represented as null in the JSON representation of the state.

Collect

The StatsActor does not collect state from other actors.

Timer

The StatsActor does not provide timer actions.