Introduction
Prerequisite
Zenskar's metering documentation provides the prerequisite conceptual knowledge.
In Zenskar, a data-ingestion API is known as a raw metric. This API helps you POST
usage data to Zenskar.
Param | Description |
---|---|
api_slug | The slug of the endpoint URL. The slug must contain alphanumeric characters, underscores, and dashes only. |
timestamp | The date and time when the usage event was captured.. |
customer_id | The ID of the customer to whom the usage data belongs. |
data | Refer the documentation on the data schema of a raw metric. |
organisation | The organization query parameter can be obtained by navigating to Settings > General. The organization query parameter accepts a valid universally unique identifier (UUID). |
Note
Irrespective of the data source type, Zenskar stores all ingested data in the form of RDBMS tables.
Tables are database objects that contain all the data in a database. In tables, data is logically organized in a row-and-column format similar to a spreadsheet.
The data type of the column is determined by the schema you defined while creating a raw metric. A sample raw metric with all available data types is shown below:
Data type |
---|
Int64 Float64 Decimal |
Bool |
Date32 DateTime64 |
String UUID |
The data type of the database column is determined by the schema you defined while creating a raw metric. A sample raw metric with all available data types is shown below:
{
"customer_id": "String",
"timestamp": "DateTime64",
"data": {
"a_string_field": "String",
"an_int64_field": "Int64",
"a_float64_field": "Float64",
"a_date32_field": "Date32",
"a_datetime64_field": "DateTime64",
"a_UUID_field": "UUID",
"a_bool_field": "Bool",
"a_decimal_field": "Decimal"
}
}
Examples
Some examples are shown below:
- If you are providing a compute resource (for example, CPU time) for rent, a raw metric schema in JSON form may look like the following:
{
"data": {
"cpu_usage_hours_per_day": "5"
},
"timestamp": "2023-05-21 09:30:38.731",
"customer_id": "[email protected]"
}
- If you are providing a compute resource (for example, CPU time) for rent, a JSON aggregate data may look like the following:
{
"data": {
"cpu_usage_hours_per_month": "300"
},
"timestamp": "2023-05-21 09:30:38.731",
"customer_id": "[email protected]"
}
The customer_id
and timestamp
are mandatory fields. A combination of these mandatory fields provides Zenskar the capability to uniquely identify a raw metric or an aggregate.
Sample API calls to send raw metrics or aggregate data to Zenskar would look like the following. The examples below use curl
utility which can act as a REST client. However, the same can be done from any REST client:
curl --location --request POST 'https://api.zenskar.com/usage/test_1' \
-H 'organisation: 23507783-d5b4-4854-b012-2bf4ea922205' \
-H 'authorization: Bearer b3VyY2VfYWNjZXNzIjp7OiIwOTkxNTEyYy0wMzI3LTQzMzEtYjQ1NS1jNzgxZjg2YWRjNzMiLCJlbWFpbF92ZXJpZmllZCI6dHJ1ZSwibmFtZSI6Ik1vaGFuIFNyZWVrYW50IiwicHJlZmVycmVkX3VzZXJuYW1lIjoibW9oYW5AemVuc2thci5jb20iLCJnaXZlbl9uYW1lIjoiTW9oYW4iLCJmYW1pbHlfbmFtZSI6IlNyZWVrYW50IiwiZW1haWwiOiJtb2hhbkB6ZW5za2FyLmNvbSJ9.K5fuK2fBlzJjQQ06Etu_H3syFjT3Q7ZtZzQqFi51YDkdJCDc-_l9JQakXWRIyeXiAM4XmbnuOorUUItNYopwfD033kQL5aI6vPnDR5DoRRkelwTam7bn94Ce83IgXbzzi0rLBzhC47lMStj-CLnNY2qdEAFRyrL8eWDsjE_8IXUB-LYb1V9I3dMOpgme77zLKySo3dHYQkBC-rZc9sNTdnaLdZy7nLrJ2-uoDvPvtOq6JLeR5ozf3bn5XEBhaHRzY23VMAgOX64-Ow_CAeVng0xIEq5P2CgqFDuNFdT3gfB8-qjKlPHdC_ndAAGGcyxbcCwrhKMgwsP6q2ZvaFDwYA' \
-H 'Content-Type: application/json' \
--data-raw '{"data":{"cpu_usage_hours_per_day":5},"timestamp":"2023-05-21 09:30:38.731","customer_id":"[email protected]"}'
curl --location --request POST 'https://api.zenskar.com/usage/test_1' \
-H 'organisation: 23507783-d5b4-4854-b012-2bf4ea922205' \
-H 'authorization: Bearer b3VyY2VfYWNjZXNzIjp7OiIwOTkxNTEyYy0wMzI3LTQzMzEtYjQ1NS1jNzgxZjg2YWRjNzMiLCJlbWFpbF92ZXJpZmllZCI6dHJ1ZSwibmFtZSI6Ik1vaGFuIFNyZWVrYW50IiwicHJlZmVycmVkX3VzZXJuYW1lIjoibW9oYW5AemVuc2thci5jb20iLCJnaXZlbl9uYW1lIjoiTW9oYW4iLCJmYW1pbHlfbmFtZSI6IlNyZWVrYW50IiwiZW1haWwiOiJtb2hhbkB6ZW5za2FyLmNvbSJ9.K5fuK2fBlzJjQQ06Etu_H3syFjT3Q7ZtZzQqFi51YDkdJCDc-_l9JQakXWRIyeXiAM4XmbnuOorUUItNYopwfD033kQL5aI6vPnDR5DoRRkelwTam7bn94Ce83IgXbzzi0rLBzhC47lMStj-CLnNY2qdEAFRyrL8eWDsjE_8IXUB-LYb1V9I3dMOpgme77zLKySo3dHYQkBC-rZc9sNTdnaLdZy7nLrJ2-uoDvPvtOq6JLeR5ozf3bn5XEBhaHRzY23VMAgOX64-Ow_CAeVng0xIEq5P2CgqFDuNFdT3gfB8-qjKlPHdC_ndAAGGcyxbcCwrhKMgwsP6q2ZvaFDwYA' \
-H 'Content-Type: application/json' \
--data-raw '{"data":{"cpu_usage_hours_per_month":300},"timestamp":"2023-05-21 09:30:38.731","customer_id":"[email protected]"}'