Skip to main content

Aggregator as a processor

Zuora

Aggregator as a processor

You can create meters for the aggregator processor.

Meter with Aggregator as a processor

To create a meter with aggregator as the processor, follow the instructions below:

  1. Create a Custom Meter. For more information, see Create a new meter using custom method.
  2. Select Aggregator as the processor.
    The Aggregator settings page is displayed.
  3. Enter a name for the aggregator component.
  4. Select the group by fields.
    Aggregator.png
  5. Select the aggregate options.
    1. Aggregate Fields: You can define the source field, operator, and result field. Create a new field if you want to use a new name or overwrite the source field if using the same name as source field.
      1. The aggregator will use “group by fields” to generate the usage unique key, which will be used to update the usage records in billing if the usage unique key is the same.
      2. The aggregator will not reduce the record rows but only add the results fields value based on the operation results. Then those usage records with the same unique key generated by the same “group by fields” can be transferred to billing and update the usage records with the aggregation results.
      3. The source field will be removed if the result field is using a new field name.
    2. Advanced Aggregation: You can set a complex Javascript or python to process the events.

  6. Click Save to save the aggregator processor settings.

The Aggregator processor supports sorting input events by a specified field before aggregation. This feature applies only to batch-mode meters and ensures consistent, predictable ordering of events within each key group.

Configuration

To enable sorting, configure the Sort Field in the Aggregator settings.

Sort Field: Enter the name of the field to sort by. The field must be convertible to an unsigned long—for example, an epoch timestamp or a numeric sequence. Both ascending and descending sort orders are supported. Sorting is applied within each key group (for example, events grouped by accountNumber or chargeNumber). To simulate a global sort, use an empty key or assign a constant value (such as global) to the key

For example, sorting within key group by eventTime. If eventTime is used as the Sort Field and accountNumber is the key, the Aggregator will sort all events for each account by timestamp before performing aggregation.

Input:


[
  { "accountNumber": "ACC-001", "eventTime": 1718203000, "usage": 8 },
  { "accountNumber": "ACC-001", "eventTime": 1718201000, "usage": 2 },
  { "accountNumber": "ACC-002", "eventTime": 1718202000, "usage": 5 },
  { "accountNumber": "ACC-002", "eventTime": 1718204000, "usage": 3 }
]

Output:

{
  "ACC-001": [
    { "eventTime": 1718201000, "usage": 2 },
    { "eventTime": 1718203000, "usage": 8 }
  ],
  "ACC-002": [
    { "eventTime": 1718202000, "usage": 5 },
    { "eventTime": 1718204000, "usage": 3 }
  ]
}

Sorting globally

To sort all events across accounts, set the key field to an empty string ("") or use a constant value such as global.

This feature is only available in batch mode. Batch mode meters are defined as no Kafka source, no Streaming API, no incremental S3 source.
Example unsupported case: S3 source + Kafka sink → Not supported, In such cases, consider changing the sink to S3, Event Store, or Zuora Usage.