Use Cases
Storage Usage
Report capacity usage by tier, region, and resource type.
Use storage metering when usage is based on capacity, files, objects, records, or retained data. This works for SaaS products, developer tools, data platforms, backups, logs, media storage, and document systems.
Model
Create a meter such as storage_gb with:
| Field | Value |
|---|---|
| Unit | gb |
| Aggregation | sum, max, or last depending on your billing model |
| Quantity | Capacity observed or capacity delta |
Useful dimensions:
tierregionresource_typestorage_class
How To Use It
Use sum when recording deltas, such as bytes added. Use last or max when recording observed capacity snapshots. Keep the event shape consistent for each meter so billing and reporting queries are easy to reason about.
This lets you answer:
- How much storage does each customer use?
- Which storage tier is growing fastest?
- Which resource types dominate capacity?
- Which regions hold the most data?
Example
Create a storage meter. Use last for snapshots or sum for deltas:
curl -X POST "$OPEN_SPANNER_BASE_URL/v1/meters" \
-H "Authorization: Bearer $OPEN_SPANNER_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"name": "storage_gb",
"description": "Observed storage capacity",
"unit": "gb",
"aggregation": "last",
"event_retention_days": 365,
"dimensions": [
{ "name": "tier", "type": "string" },
{ "name": "region", "type": "string" },
{ "name": "resource_type", "type": "string" },
{ "name": "storage_class", "type": "string" }
]
}'Record a capacity snapshot:
curl -X POST "$OPEN_SPANNER_BASE_URL/v1/usages" \
-H "Authorization: Bearer $OPEN_SPANNER_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"idempotency_key": "storage_org_123_2026_06_19",
"subject": "org_123",
"meter": "storage_gb",
"quantity": 482.7,
"metadata": {
"tier": "enterprise",
"region": "us-east",
"resource_type": "object",
"storage_class": "hot"
}
}'