Step 2: Ingest usage events via API

To process customer service consumption, Zenskar's Usage module utilizes a two-phase approach for API-based ingestion:

  1. You will define the schema of your usage events in Zenskar, setting up dedicated API endpoints for each event type.
  2. You will send your raw usage data to these configured endpoints.

Prerequisites


2.1: Define usage event structure

Before ingesting data, you must define the schema for each type of usage event within Zenskar. This creates specific API endpoints (slugs) to which your client system will then send the actual usage data. We will define two separate usage event types: one for Compute Usage and one for Storage Usage.

You will configure two separate usage event definitions through the Zenskar dashboard using the "Add Usage Event" UI.

  1. Log in to your Zenskar dashboard.
  2. Navigate to the Usage > Usage Events.
  3. Click "+ ADD USAGE EVENT" to open the configuration form.

First definition: For compute usage events

  • Usage Event Name: Enter Compute events. This will create the endpoint https://api.zenskar.com/usage/compute_events.
  • API Slug Endpoint: Will display https://api.zenskar.com/usage/compute_events.
  • Root Fields:
    • customer_id (Data type: String)
    • timestamp (Data type: DateTime64)
  • Your Data Schema:
    • Click + ADD NEW DATA FIELD and add:
      • cpu_hours_consumed (Data type: Float64)
      • region (Data type: String)
  • Order By: Ensure timestamp is selected or entered.
  • Review the "Data Schema Preview" and click "ADD USAGE EVENT".

Second definition: For storage usage events

  • Usage Event Name: Enter Storage events. This will create the endpoint https://api.zenskar.com/usage/storage_events.
  • API Slug Endpoint: Will display https://api.zenskar.com/usage/storage_events.
  • Root Fields:
    • customer_id (Data type: String)
    • timestamp (Data type: DateTime64)
  • Your Data Schema:
    • Click "ADD NEW DATA FIELD" and add:
      • storage_gb_month (Data type: Float64)
      • storage_tier (Data type: String)
  • Order By: Ensure timestamp is selected or entered.
  • Review the "Data Schema Preview" and click "ADD USAGE EVENT".

2.2: Ingest usage events

Once you have defined your usage event structures (e.g., compute_events and storage_events in the previous sub-step), your client system can now push actual usage data to the specific API endpoint generated for each, or upload it directly via the Zenskar Dashboard.

You can manually add single usage events or upload them in bulk via CSV directly through the Zenskar dashboard. This uses the usage event structure you defined in Step 2.1.

  1. Log in to your Zenskar dashboard.
  2. Navigate to the Usage module, then select the specific Usage Event you want to ingest data for (e.g., "compute_events" or "storage_events").
  3. You will see an interface similar to the one below, displaying ingested events for that specific event type:
  4. To add data:
    • Upload CSV: Click the "UPLOAD CSV" button. You will need a CSV file formatted according to the schema you defined in Step 2.1 for that specific usage event type (e.g., if uploading for compute_events, columns for customer_id, timestamp, cpu_hours_consumed, region).
    • Add Single Event: Look for an option to "Add single event" (often a button or a menu item near the "Upload CSV" button). This will open a form where you can manually enter details for a single usage event based on its defined schema.
  5. After uploading or adding, the events will appear in the "Events Table" for the selected usage event type.