# Meter Usage Data at Scale

### Overview

The most critical and fundamental steps to get started with usage-based billing and pricing are to measure accurate usage data and collect them for billing/pricing. Paigo does deep integration with SaaS application at every layer to extract usage out in real-time and keep track of the usage amount for the SaaS business.

The architecture diagram below shows how Paigo meteres product usage data from every layer of SaaS application stack:

<figure><img src="https://3896284822-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F6A4R1rYAI87V2R47cxIl%2Fuploads%2FAfSEteMODPs0D8kIzX6I%2Fmetering.png?alt=media&#x26;token=b7213155-72e8-423b-a893-3b5610c7b90c" alt=""><figcaption></figcaption></figure>

The table below summarizes usage meter architecture:

<table><thead><tr><th width="306.3333333333333">Layer</th><th>Integration Method</th></tr></thead><tbody><tr><td><strong>Application</strong></td><td>REST API, Amplitude, Mixpanel</td></tr><tr><td><strong>Platform (Storage-based)</strong></td><td>AWS S3</td></tr><tr><td><strong>Platform (Streaming-based)</strong></td><td>Confluent Kafka, AWS Kinesis</td></tr><tr><td><strong>Platform (Query-based)</strong></td><td>PostgreSQL, Bring-your-own-DB</td></tr><tr><td><strong>Platform (Agent-based)</strong></td><td>Prometheus, Grafana, Vector, Logstash</td></tr><tr><td><strong>Infrastructure</strong></td><td>AWS, Azure, Docker, Kubernetes</td></tr></tbody></table>

### Ingest Usage Record with Dashboard

From Paigo Dashboard, usage data can be recorded without writing code. It is great for trying usage data ingestion and getting started with more programmatic way of usage data collection automation. To try creating usage record with dashboard, it is required to have a dimension and a customer profile created. See [getting-started-with-paigo](https://docs.paigo.tech/overview/getting-started-with-paigo "mention") chapter for an example setup.

To ingest usage record, navigate to **Customer** tab and select a customer profile from the customer table. In the customer profile view, scroll down to **Usage Monitoring** widget. In the dropdown on the top right corner of the widget, select the dimension to record usage with, and click on the **Record Usage** button. In the **Record Usage** form, the fields of **Customer ID**, and **Dimension ID**, are all prefilled. Set value for the following fields with proper values:

* **Record Value**: a numerical value represent the amount of usage
* **Timestamp**: the time of when the usage record is measured. Usually it marks the end of the period when usage amount occurs.
* **Record Metadata (Key - Value Pair)**: additional metadata to be stored on the usage record, such as environment, purpose, owner, developer, contract number, or any arbitrary data to be associated with this usage record. Metadata can be used for analytics purpose in the future. Click on **Add Metadata** to add the key-value pair to metadata. Double click previewed Metadata table cells to edit added metadata, and press **Enter** to save the edits.

See the screenshot below for an example.

<figure><img src="https://3896284822-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F6A4R1rYAI87V2R47cxIl%2Fuploads%2FzFFk5qbg74tA0fRZjlWp%2FCursor_and_Paigo_Customer_Portal.png?alt=media&#x26;token=ba614304-9044-42ca-8c63-deb1ab0c0fd6" alt=""><figcaption></figcaption></figure>

In the **Preview Record Code Snippet** section down below, the code to create the same usage record is provided. Click on the **Copy** button on the top right corner of **Preview Record Code Snippet** to copy the code. Click **Submit** button to submit the usage record.
