curl --request POST \
--url https://api.withorb.com/v1/metrics \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '{
"metadata": {},
"sql": "SELECT sum(bytes_downloaded) FROM events WHERE download_speed = '\''fast'\''",
"name": "Bytes downloaded",
"item_id": "<string>",
"description": "Sum of bytes downloaded in fast mode"
}'
{
"metadata": {},
"id": "<string>",
"name": "<string>",
"description": "<string>",
"status": "active",
"item": {
"metadata": {},
"id": "<string>",
"name": "<string>",
"created_at": "2023-11-07T05:31:56Z",
"external_connections": [
{
"external_connection_name": "stripe",
"external_entity_id": "<string>"
}
]
}
}
This endpoint is used to create a metric using a SQL string. See SQL support for a description of constructing SQL queries with examples.
curl --request POST \
--url https://api.withorb.com/v1/metrics \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '{
"metadata": {},
"sql": "SELECT sum(bytes_downloaded) FROM events WHERE download_speed = '\''fast'\''",
"name": "Bytes downloaded",
"item_id": "<string>",
"description": "Sum of bytes downloaded in fast mode"
}'
{
"metadata": {},
"id": "<string>",
"name": "<string>",
"description": "<string>",
"status": "active",
"item": {
"metadata": {},
"id": "<string>",
"name": "<string>",
"created_at": "2023-11-07T05:31:56Z",
"external_connections": [
{
"external_connection_name": "stripe",
"external_entity_id": "<string>"
}
]
}
}
API Keys can be issued in the Orb's web application.
Created
The Metric resource represents a calculation of a quantity based on events. Metrics are defined by the query that transforms raw usage events into meaningful values for your customers.
Was this page helpful?