Skip to end of metadata
Go to start of metadata

You are viewing an old version of this page. View the current version.

Compare with Current View Page History

« Previous Version 6 Next »

When the data is sent out of meter processor, also known as flush of the record, a record in json format will be sent for each meter associated with the meter processor.

Irrespective of whether meter being updated or not during the last metering period, the meter is always flushed when it’s period ends. meters are not flushed after the Active To has been passed for the meter type linked except meters which has been updated during the current metering period.

Usage audit are generated when the input data is outputted from meter processor.

The metered record can be viewed in JSON format in the Meter Inspector

view-session.png

These are the fields which are sent to downstream systems in JSON format:

Field

Purpose

id

The unique ID of meter.

userId

Unique ID of the user the meter belongs to, for example an email address, user name or MSISDN number.

meterTypeId

The unique ID of the meter type that the meter aggregate usage for.

meterTypeName

Name of the meter type this meter is created using.

timezone

The timezone that should be applied for reset time. Defined on the meter type of this meter.

meterKey

The meter key for the meter processor aggregating the usage for the meter.

value

The current value of the meter, updated based on guiding rules and aggregation type defined on meter type.

unit

Unit which this meter is measuring. Defined on the meter type of this meter.

createdAt

UTC timestamp of when meter was created.

updatedAt

UTC timestamp of when meter was last updated.

periodStart

UTC timestamp from when the metering period has started. This is calculated based on when last period has ended.

periodEnd

UTC timestamp when the metering period has ended. This is calculated based on reset schedule.

groups

Granular breakdown of the aggregated values, grouped by the guiding rules defined in the Meter Configuration . Each group is represented by an array containing the parameters key, fields, and value.

carryFirst

First occurrence of one or many fields that should be carried over from usage record. Configured in other operations in Meter Configuration

carryLast

Last occurrence of one or many fields that should be carried over from usage record. Configured in other operations in Meter Configuration

deleteOnReset

If true, the meter will be deleted when ongoing metering period ends. Can be updated using update Meter API.

meterMetaData

Additional meta information related to usage ingestion example, datetime when the first and last record matched this meter.

Example of metered output record:

{
  "carryFirst": {
    "country": "Norway"
  },
  "carryLast": {
    "timestamp": "2023-07-05T22:01:04.431Z"
  },
  "createdAt": "2023-07-01T00:00:00.000Z",
  "deleteOnReset": false,
  "groups": [
    {
      "fields": {
        "API name": "createUser"
      },
      "key": "API name:createUser",
      "value": 10
    },
    {
      "fields": {
        "API name": "updateCounter"
      },
      "key": "API name:updateCounter",
      "value": 15
    }
  ],
  "id": "8a76066d-ff29-417c-a18e-abde22e44310",
  "meterKey": "a1f8797b-c827-4483-b6cf-6d3d3baa18a7",
  "meterMetaData": {
    "firstEvent": "2023-07-01T13:37:11.111Z",
    "lastEvent": "2023-07-05T22:01:04.431Z"
  },
  "meterTypeId": "645ed240-02b5-400c-9a3c-21857e8f2ac4",
  "meterTypeName": "Usage based API counter",
  "periodEnd": "2023-08-01T00:00:00.000Z",
  "periodStart": "2023-07-01T00:00:00.000Z",
  "timezone": "Etc/UTC",
  "unit": "requests",
  "updatedAt": "2023-07-05T22:01:04.431Z",
  "userId": "user0@example.com",
  "value": 25
}

Meter Reset

When flush happens, the values of the meters are also reset to their initial value, for example value is set to 0 or groups are removed etc, to empty the bucket. At the same time meters are prepared for the next metering period and Period start and Period end is updated based on when flush happen and Reset schedule.

If the meters are flushed by Period end in Meter Processor , then new period start is set to the when last period has ended and period end is calculated based on the Reset schedule of the respective meter type. Example, meter type has reset schedule everyday at midnight -

Ongoing period: Period start - 1st Jan 00:00 and Period end 2nd Jan 00:00.

If stream runs on 2nd Jan on 02:00, New period: Period start at 2nd Jan 00:00 and Period end at 3rd Jan 00:00.

If stream does not run 2nd Jan and runs on 3rd Jan at 02:00, New period: Period start at 2nd Jan 00:00 and Period end at 4th Jan 00:00.

It is done in this way because before processing the incoming usage data stream scans for meters whose period has ended and flush them, so in later case when stream runs on 3rd Jan, usage data from the 2nd of Jan post midnight is included in the new period and usage data up to 2nd midnight is already aggregated in metered and flushed record.

If the meters are flushed by Stream execution in Meter Processor , the period end of the flushed metered record is set to the time of the flush. The new Period start of the meter in the stream is also set to the time of the flush, and the Period end is calculated using the meter type Reset schedule.

Period start and Period end for a meter can be checked using a Meter Inspector.

  • No labels