Guides
Usage Metering

Meter Event Schema

6min

The default ingest event schema supported by Amberflo is as follows:

Text


Amberflo supports the following input formats

  • JSON
  • NDJSON
  • CSV

Amberflo also supports defining a custom schema, which transforms the input into Amberflo ingest events. This guide explains how to use a custom schema for ingesting meter events.

JSON format

Sample Input in JSON format.

JSON


NDJSON format

Amberflo also supports the NDJSON format, where each record is separated by a new line.

Sample Input in NDJSON format.

Text


CSV format

Sample Input in CSV format.

Text


Difference in behavior for CSV and JSON inputs

If a custom schema is not used, then for CSV input the columns not part of Amberflo default schema will be converted to dimensions, whereas for JSON input keys that are not part of Amberflo default schema are excluded.

Let's take a look at the below table to understand this.



Input

Transformed Input



CSV

meterApiName meterValue meterTimeInMillis customerId region m1 1 1714070079000 c1 us-west-2

{ "meterApiName": "m1", "meterValue": 1, "meterTimeInMillis": 1714073679000, "customerId": "c1", "dimensions": { region": "us-west-2" } }



JSON

{ "meterApiName": "m1", "meterValue": 1, "meterTimeInMillis": 1714073679000, "customerId": "c1", "region": "us-west-2" }
{ "meterApiName": "m1", "meterValue": 1, "meterTimeInMillis": 1714073679000, "customerId": "c1" }











As we can see the region column/key in CSV and JSON inputs does not belong to the default Amberflo schema. So we can see in the transformed input that the region column has been transformed into dimensions for CSV input whereas it is excluded for the JSON input.

If a custom schema is used then only the columns/key mapped in the schema sub-components will be considered rest will be excluded for both CSV and JSON.

Defining custom ingest schema

The Amberflo Custom Ingest Schema API lets you define your own custom schema based on your events. This custom schema can be used with both CSV and JSON inputs. The schema has sub-components that define the mapping of a particular source column-name/json-key to the Amberflo ingest event parameter.