Find a usage-event collection
Find a usage-event collection in the Usage Events list by name. You can also narrow the list with filters and sorting. The list shows the data schema of each usage-event collection.Prerequisites
- You need a role with the Can Read Usage Event permission. See Permissions.
Search for a usage-event collection by name
- Go to Usage > Usage Events.
- In Search Usage Event, enter part of the name.
- Select the usage-event collection from the results.
Filter the list
- Go to Usage > Usage Events.
- Click FILTER.
- In Filter by…, select Name, API Slug, or Created At.
- Select a condition and a value.
- Click APPLY FILTER.
Sort the list
- Go to Usage > Usage Events.
- Click a column header. The list sorts by that column in ascending order.
- Click the column header again to sort in descending order.
- Click the column header a third time to remove the sorting.
See the data schema of a usage-event collection
- Go to Usage > Usage Events.
- In the Data Schema column of the usage-event collection, click View.
Create a usage-event collection
Create a usage-event collection for each kind of consumption that you record. The name and the API slug of a usage-event collection cannot change after you create it.Prerequisites
- You need a role with the Can Create Usage Event and Can Read Usage Event permissions. See Permissions.
- To read usage events from Amazon S3, the organization needs a bucket connection. See Connect the bucket in Zenskar.
Enter the name and the API slug
- Go to Usage > Usage Events.
- Click ADD USAGE EVENT. The Add Usage Event screen opens.
- In Usage Event Name, enter a name. The name can contain letters, digits, underscores, and spaces.
- Under API Slug Endpoint, check the API slug. By default, Follow the usage event name is selected. The API slug then follows the name.
- Optional: To choose a different API slug, clear Follow the usage event name. Enter the API slug. The API slug must start and end with a letter or a digit. In between, it can also contain underscores and hyphens.
Turn on S3 ingestion
This step is optional. The screen shows the S3 ingestion options only when the organization has a bucket connection.- Turn on Enable S3 ingestion for this usage event. S3 Directory Name shows the folder that Zenskar reads, after the name of the bucket. By default, the folder is the API slug.
- Optional: In Error / DLQ Directory Name, enter an error folder. Use a relative path without a trailing slash. The field shows only when the organization has an ingestion-error bucket.
Define the data schema
You cannot remove or rename a data field after you create the usage-event collection. You cannot change its data type either. Check each data field before you save.
- Under Root Fields, check the two root fields,
customer_idandtimestamp. They cannot change. - Under Your Data Schema, click + ADD NEW DATA FIELD.
- In Data field, enter the name of the data field. Zenskar replaces spaces with underscores.
- In Data type, select the data type. See Data fields.
- Repeat steps 2 to 4 for each data field. To remove a data field before you save, click its delete icon.
- Check Data Schema Preview. It shows the data schema as JSON.
- Click ADD USAGE EVENT.
Fix a failed save
- Zenskar rejects the usage-event collection when another usage-event collection in the organization has the same API slug. Choose another API slug.
- Zenskar does not save the usage-event collection when two data fields have the same name. Rename or remove one of them.
- When creation takes longer than usual, Zenskar finishes it in the background. Check Usage Events again later. If the usage-event collection does not appear, create it again.
- When Zenskar creates the usage-event collection but cannot turn on S3 ingestion, turn it on from the screen of the usage-event collection. See Set up S3 ingestion for a usage-event collection.
View a usage-event collection
The screen of a usage-event collection shows its API slug endpoint, its data schema, a sample request, and its latest usage events.Prerequisites
- You need a role with the Can Read Usage Event permission. See Permissions.
Open the screen of a usage-event collection
- Go to Usage > Usage Events.
- Click the usage-event collection.
Copy the API slug endpoint
- On the screen of the usage-event collection, next to API Slug Endpoint, click the copy icon.
https://api.zenskar.com/usage/ followed by the API slug.
See the data schema
- On the screen of the usage-event collection, next to Data Schema, click View.
Browse the usage events
The Events Table shows the 20 usage events with the latesttimestamp. The newest usage event comes first. It has one column for each field of the usage events.
- To show usage events that just arrived, click REFRESH TABLE. A usage event can take a few seconds to show.
- To narrow the table, click FILTER.
- In Filter by…, select a field.
- Select a condition and a value. The conditions depend on the data type of the field.
- Click APPLY FILTER.
Send usage events through the API
Send usage events from your systems to the API slug endpoint of a usage-event collection. The screen of the usage-event collection shows a sample request with the API slug endpoint and the headers filled in.Prerequisites
- You need a role with the Can Read Usage Event permission to open the sample request. See Permissions.
- You need an API key of the organization. See API keys.
- The usage-event collection must exist. See Create a usage-event collection.
Copy the sample request
- Go to Usage > Usage Events. Click the usage-event collection.
- Next to Sample Request, click View. The Sample Request window shows a
curlrequest. - Click the copy icon.
Send a usage event
- In the copied request, replace
<your-api-key>with your API key. Keep theorganisationheader. It holds the ID of your organization. - Replace the text after
--data-rawwith your usage event. Put the root fields at the top level and the data fields insidedata. WritetimestampasYYYY-MM-DD HH:MM:SS. - Send the request.
api_calls:
Send several usage events in one request
- In the request, replace the single usage event after
--data-rawwith a JSON array of usage events. - Send the request.
Add a data field
Add a data field to the data schema of an existing usage-event collection. Usage events that arrived before you add the data field have no value for it.Prerequisites
- You need a role with the Can Update Usage Event and Can Read Usage Event permissions. See Permissions.
Add the data field
You cannot remove or rename a data field after you add it. You cannot change its data type either. Check the name and the data type before you submit.
- Go to Usage > Usage Events. Click the usage-event collection.
- Click NEW FIELD TO DATA SCHEMA. The section expands.
- In Data field name, enter the name. Zenskar replaces spaces with underscores.
- In Data field type, select the data type. See Data fields.
- Click SUBMIT.
Set up S3 ingestion for a usage-event collection
Turn on S3 ingestion for a usage-event collection. Choose the folders that Zenskar uses in the S3 buckets of the organization. Each usage-event collection has its own folder.Prerequisites
- You need a role with the Can Update Usage Event and Can Read Usage Event permissions. See Permissions.
- The organization needs a bucket connection. See Connect the bucket in Zenskar.
Turn on S3 ingestion
- Go to Usage > Usage Events. Click the usage-event collection.
- Under S3 Ingestion, turn on the switch. The folder fields open.
- In S3 Directory Name, check the folder. It starts as the API slug of the usage-event collection, after the name of the bucket. Use a relative path without a trailing slash, and without
.or..as a part of the path. - Optional: In Error / DLQ Directory Name, enter an error folder. The field shows only when the organization has an ingestion-error bucket.
- Click SAVE.
Change the folders
- On the screen of the usage-event collection, under S3 Ingestion, click Edit.
- Change S3 Directory Name or Error / DLQ Directory Name.
- Click SAVE. To discard the change, click CANCEL.
Turn off S3 ingestion
- On the screen of the usage-event collection, under S3 Ingestion, turn off the switch.
Download usage events
Download the usage events of a usage-event collection as a CSV file. You can download all usage events, or only the usage events that match the filters of the Events Table. One download holds at most 50,000 usage events.Prerequisites
- You need a role with the Can Read Usage Event permission. See Permissions.
Download the usage events
- Go to Usage > Usage Events. Click the usage-event collection.
- Optional: Filter the Events Table. See Browse the usage events.
- Click DOWNLOAD EVENTS. The Export Events window shows the number of usage events and the expected duration of the download.
- If the Events Table has filters, the window lists them under Use filters. Use filters is on. To download all usage events instead, turn off Use filters.
- Click EXPORT. Keep the window open until the download finishes.
events_export.csv.
When the number of usage events is above 50,000, Zenskar does not download them. Add filters until the number is 50,000 or less. Download each part separately.
Upload usage events from a CSV file
Upload a CSV file with one row for each usage event. Zenskar checks every row against the data schema before it stores any row. If one row fails the check, Zenskar stores none of the rows.Prerequisites
- You need a role with the Can Create Usage Event and Can Read Usage Event permissions. See Permissions.
- The CSV file must be at most 100 MB.
- The CSV file must have one column for each field of the data schema, and no other columns. The column headers are the field names:
customer_id,timestamp, and the name of each data field withoutdata.in front, such asendpoint.
Download a sample file
- Go to Usage > Usage Events. Click the usage-event collection.
- Click UPLOAD CSV. The Upload CSV window opens.
- Click Download sample CSV file.
sample.csv. It has the columns that the data schema needs and 100 rows of example values.
Upload the file
- On the screen of the usage-event collection, click UPLOAD CSV.
- Click Click to upload. Select the file. You can also drag the file into the window.
- If the window shows Date Format and Timestamp Format, select the formats that the file uses. The lists show the formats that Zenskar detects in the file.
- Optional: To check the rows, click Preview. To download the rows as Zenskar reads them, click Processed CSV.
- Click IMPORT CSV DATA. Keep the window open until the upload finishes.
Fix a failed upload
- When the columns do not match the data schema, Zenskar rejects the file before the upload starts. Make the headers match the field names, with one column for each field.
- When a row fails the check, Zenskar stores none of the rows. Zenskar shows the number of the row. Fix the row. Upload the file again.
- When the upload stops partway after the check, for example because of a network error, some usage events can already be stored. Check the Events Table before you upload again. A usage event cannot be deleted. A second upload of the same rows stores them twice.
Add a single usage event
Add one usage event from the dashboard, for example to test a usage-event collection.Prerequisites
- You need a role with the Can Create Usage Event and Can Read Usage Event permissions. See Permissions.
Add the usage event
- Go to Usage > Usage Events. Click the usage-event collection.
- Next to UPLOAD CSV, click the arrow. Click Add a single event. The Add New Event panel opens.
- In Customer ID, enter the customer ID.
- Under Timestamp, in Date, select the date.
- In Time, enter the time.
- Optional: Enter a value for each data field. The panel shows one entry for each data field, labeled with its name and data type. A Bool data field has True and False. An Int64 data field takes only whole numbers.
- Click ADD EVENT.