Find a usage-event collection
Prerequisites
- You need a role with the Can Read Usage Event permission.
Steps
- Go to Usage > Usage Events. The list shows the usage-event collections of your organization.
- Optional: To narrow the list, click FILTER. In Filter by…, select Name, API Slug, or Created At. Select a condition and a value, and click APPLY FILTER. The list shows only the usage-event collections that match. To remove all filters, click Clear All Filters.
- Optional: To sort the list, click a column header. Click it again to sort in descending order, and a third time to remove the sorting.
- Optional: To see the data schema of a usage-event collection, click View in its Data Schema column. The Data Schema window shows the data schema as JSON.
- In Search Usage Event, enter part of the name, and select the usage-event collection from the results. You can also click the usage-event collection in the list.
Create a usage-event collection
Prerequisites
- You need a role with the Can Create Usage Event and Can Read Usage Event permissions.
- To read usage events from Amazon S3, your organization needs a bucket connection. See Connect the bucket in Zenskar.
Steps
You cannot change the name or the API slug after you create the usage-event collection. You cannot remove or rename a data field, or change its data type. Check them before you click ADD USAGE EVENT.
- Go to Usage > Usage Events.
- Click ADD USAGE EVENT. The Add Usage Event screen opens.
- In Usage Event Name, enter a name.
- Under API Slug Endpoint, check the API slug. By default, Follow the usage event name is selected, and the API slug follows the name.
- Optional: To choose a different API slug, clear Follow the usage event name, and enter the API slug.
- Optional: To read the usage events of the usage-event collection from Amazon S3, turn on Enable S3 ingestion for this usage event. The switch shows only when your organization has a bucket connection. 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. The field shows only when your organization has an ingestion-error bucket.
-
Under Root Fields, check the two root fields,
customer_idandtimestamp. - Under Your Data Schema, click + ADD NEW DATA FIELD.
- In Data field, enter the name of the data field.
- In Data type, select the data type. See Data fields: the details that you add.
- Repeat steps 9 to 11 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.
View a usage-event collection
Prerequisites
- You need a role with the Can Read Usage Event permission.
Steps
- Go to Usage > Usage Events.
- Click the usage-event collection. The screen opens with the name of the usage-event collection as its title.
-
Optional: To copy the API endpoint, click the copy icon next to API Slug Endpoint.
The API endpoint is
https://api.zenskar.com/usage/followed by the API slug. - Optional: To see the data schema, click View next to Data Schema. The Data Schema window shows the data schema as JSON.
-
Check the Events Table.
The table shows the 20 usage events with the latest
timestamp, newest first. It has one column for each field of the usage events. - Optional: To show usage events that just arrived, click REFRESH TABLE. A usage event can take a few seconds to show.
- Optional: To narrow the table, click FILTER. In Filter by…, select a field. Select a condition and a value, and click APPLY FILTER. The table shows the 20 latest usage events that match. To see all matching usage events, download them. See Download usage events.
Add a data field
Prerequisites
- You need a role with the Can Update Usage Event and Can Read Usage Event permissions.
Steps
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 click SUBMIT.
- Go to Usage > Usage Events, and click the usage-event collection.
- Click NEW FIELD TO DATA SCHEMA. The section expands.
- In Data field name, enter the name.
- In Data field type, select the data type. See Data fields: the details that you add.
- Click SUBMIT. Usage events that arrived before you add the data field have no value for it.
Upload usage events from a CSV file
Prerequisites
- You need a role with the Can Create Usage Event and Can Read Usage Event 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 asregion.
Steps
- Go to Usage > Usage Events, and click the usage-event collection.
- Click UPLOAD CSV. The Upload CSV window opens.
-
Optional: To get a file with the right columns, click Download sample CSV file.
Your browser saves
sample.csv. It has the columns that the data schema needs, and 100 rows of example values. - Click Click to upload, and 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. 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. The dashboard shows the number of the row.
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.
Steps
- Go to Usage > Usage Events, and click the usage-event collection.
- Next to UPLOAD CSV, click the arrow, and 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.
- Click ADD EVENT.
Send usage events through the API
Prerequisites
- You need a role with the Can Read Usage Event permission to open the sample request.
- You need an API key of your organization. See API keys.
- The usage-event collection must exist. See Create a usage-event collection.
Steps
- Go to Usage > Usage Events, and click the usage-event collection.
-
Next to Sample Request, click View.
The Sample Request window shows a
curlrequest to the API endpoint of the usage-event collection, with the headers filled in. - Click the copy icon. To create an API key from the window, click Create an API Key.
-
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. The following request sends one usage event to the usage-event collection with the API slugapi_calls:To send several usage events in one request, replace the single usage event with a JSON array of usage events: - Send the request.
Set up S3 ingestion for a usage-event collection
Prerequisites
- You need a role with the Can Update Usage Event and Can Read Usage Event permissions.
- Your organization needs a bucket connection. See Connect the bucket in Zenskar.
Steps
- Go to Usage > Usage Events, and 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.
- Optional: In Error / DLQ Directory Name, enter an error folder. The field shows only when your organization has an ingestion-error bucket.
- Click SAVE.
Change the S3 folders of a usage-event collection
Prerequisites
- You need a role with the Can Update Usage Event and Can Read Usage Event permissions.
Steps
- Go to Usage > Usage Events, and click the usage-event collection.
- Under S3 Ingestion, click Edit.
- Change S3 Directory Name, or the error folder in Error / DLQ Directory Name.
- Click SAVE. To discard the change, click CANCEL.
Turn off S3 ingestion for a usage-event collection
Prerequisites
- You need a role with the Can Update Usage Event and Can Read Usage Event permissions.
Steps
- Go to Usage > Usage Events, and click the usage-event collection.
- Under S3 Ingestion, turn off the switch.
Download usage events
Prerequisites
- You need a role with the Can Read Usage Event permission.
Steps
One download holds at most 50,000 usage events. For more, add filters until the number is 50,000 or less, and download each part separately.
- Go to Usage > Usage Events, and click the usage-event collection.
- Optional: Filter the Events Table. See View a usage-event collection.
- 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, which 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.
See Export Events window.