---
title: Meter Event Schema
slug: docs/meter-ingestion-event-schema
createdAt: 2024-07-15T13:37:44.598Z
---

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

```none
{
    "customerId": string,
    "meterApiName": string,
    "meterValue": number,
    "meterTimeInMillis": number,
    "uniqueId": string
    "dimensions": map<string, string>
}
```

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
[{
     "customerId": "customer-123",
     "meterApiName": "ComputeHours",
     "meterValue": 5,
     "meterTimeInMillis": 1619445706909,
     "dimensions": {
        "region": "us-west-2",
        "az": "az1"
     }
}, {
    ...
}]
```

## NDJSON format

Amberflo also supports the [NDJSON format](https://github.com/ndjson/ndjson-spec), where each record is separated by a new line.

Sample Input in NDJSON format.

```none
{ "customerId": "customer-123", "meterApiName": "ComputeHours", "meterValue": 5, "meterTimeInMillis": 1619445706909 }
{ "customerId": "customer-321", "meterApiName": "ComputeHours", "meterValue": 4, "meterTimeInMillis": 1619445712341 }
{ "customerId": "customer-123", "meterApiName": "ComputeHours", "meterValue": 1, "meterTimeInMillis": 1619445783456 }
```

## CSV format

Sample Input in CSV format.

```none
meterApiName,meterValue,meterTimeInMillis,customerId,region
ComputeHours,5,1619445706909,customer-123,us-west-2
ComputeHours,4,1619445712341,customer-321,us-east-1
ComputeHours,1,1619445783456,customer-123,us-west-2
```

### Difference in behavior for CSV and JSON inputs

If a custom schema is not provided:

- For **CSV input**, any columns that are not part of the Amberflo default schema will be automatically treated as dimensions.
- For **JSON input**, any keys that do not match the default schema will be ignored (they will not be included as dimensions or stored).

The table below illustrates how this behavior works.

|      | **Input**                                                                                                                                                                       | Transformed Input                                                                                                                                                                   |   |
| ---- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | - |
| CSV  | **meterApiName   meterValue   meterTimeInMillis   customerId   region**<br />m1                        1                     1714070079000       c1                   us-west-2 | \{<br />"meterApiName": "m1",<br />"meterValue": 1,<br />"meterTimeInMillis": 1714073679000,<br />"customerId": "c1",<br />"dimensions": \{<br />region": "us-west-2"<br />}<br />} |   |
| JSON | \{<br />"meterApiName": "m1",<br />"meterValue": 1,<br />"meterTimeInMillis": 1714073679000,<br />"customerId": "c1",<br />"region": "us-west-2"<br />}                         | \{<br />"meterApiName": "m1",<br />"meterValue": 1,<br />"meterTimeInMillis": 1714073679000,<br />"customerId": "c1"<br />}                                                         |   |
|      |                                                                                                                                                                                 |                                                                                                                                                                                     |   |

As shown in the example, the region column/key is not part of the default Amberflo schema. In the transformed input:

- For **CSV input**, the region column is automatically included as a dimension.
- For **JSON input**, the region key is excluded entirely.

When a **custom schema** is used, only the fields explicitly mapped in the schema’s sub-components are considered. All other fields are excluded—this applies to both CSV and JSON inputs.

## 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.
