Raw metrics

Overview

Fig. 3: Raw metrics or aggregates ingested via Zenskar API

Fig. 1: Raw metrics or aggregates ingested via Zenskar API

Your can integrate Zenskar in your application workflow by configuring a data-ingestion API. You can call this API like any other REST API and help Zenskar ingest your raw metrics or aggregates. Zenskar expects the input data in JavaScript Object Notation (JSON) format: a universal data-interchange format like XML.


Set up a data-ingestion API in Zenskar

  1. To set up a data-ingestion API, navigate to Metering > Raw Metrics page.
  2. Click on the + ADD RAW METRIC button.
  3. On the Add Raw Metric page, fill in the following details.
FieldDescription
Raw metric nameA descriptive name.
API slug endpointThe slug of the endpoint URL which is automatically derived from the raw metric name. However, you can override the auto-generated name. The slug must contain alphanumeric characters, underscores, and dashes only. For example, if the raw metric name is a raw metric, the slug generated will be a_raw_metric.
Root fieldscustomer_id and timestamp are read-only root fields mandatory for Zenskar.
Your data schemaDefine the schema of the JSON data you wish to send to Zenskar. Zenskar will use this schema to create tables.
Order byZenskar orders the data by timestamp.
Data schema previewYou can preview the data schema:

{
"customer_id": "String",
"timestamp": "DateTime64",
"data": {
"call_minutes": "Float64"
}
}
  1. Click on the ADD RAW METRIC button to save the API.

Some examples are shown below:

  1. 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]"
}
  1. 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]"}'

The JSON data you send us is securely stored in our database as a table after the requisite transformations are applied.

πŸ“š

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.

Push data to Zenskar

Integrate the data-ingestion APIs in your application workflow

πŸ‘·

Engineering effort required

Integrating Zenskar data-ingestion REST API in your application workflow will require engineering effort. However, to test all you need is a REST client. Prominent examples of REST clients are Postman (feature-rich) and Thunder Client (lightweight).

Upload a Zenskar-compatible CSV

In addition to setting up data-ingestion APIs for automation, Zenskar lets you upload raw metrics manually in the form os a Zenskar-compatible, comma-separated values (CSV) files.

  1. To set up a data-ingestion API, navigate to Metering > Raw Metrics page.
  2. Click on the row containing the API you are interested in.
  1. On the View Raw Metric page, click on the UPLOAD CSV button. The Upload CSV dialog pops up.
  2. On the Upload CSV dialog, you can:
    • drag and drop or click to upload a Zenskar-compatible CSV file of maximum size 10 MB
    • generate and download a sample Zenskar-compatible CSV of schema appropriate for the API
  1. On the Upload CSV dialog, click on the IMPORT CSV DATA button.