Azion CLI data-stream
Create, list, describe, update, and delete Data Stream streams and templates with the Azion CLI, with every flag, its type, and its default.
The Azion CLI data-stream commands create, list, describe, update, and delete the streams and templates of Data Stream. Every verb takes a subcommand: streams acts on a stream, named with --stream-id, and templates acts on a template, named with --template-id. azion list data-stream also takes data-sources. The commands exist only on accounts that use API v4. The options every command accepts, such as --format, --out, and -y, are on Global options.
Create
azion create data-stream takes the streams or the templates subcommand.
Streams
azion create data-stream streams creates a stream from a JSON file that holds the stream object:
| Flag | Short | Type | Default | Description |
|---|---|---|---|---|
--file | — | string | — | Path to a JSON file with the stream object. Use - to read the JSON from standard input. Without it, the command asks for the path. |
The command has no flag for the template. The template ID goes in the render_template item of transform, and a file without that item fails with this error:
This file, stream.json, creates a stopped stream named my-stream. It sends every Activity History event, rendered by the Activity History Collector preset template, to an HTTP endpoint:
inputs names the data source by its slug, transform holds the sampling rate and the template ID, and outputs holds the one endpoint. For each field and the values it takes, refer to Stream settings.
Saving an active stream that has a sampling item deactivates every other stream on the account, and the API returns no error. To run several streams at once, give each one a filter_workloads item instead, as described in Stream settings.
Pass the file to the create command:
The command prints the ID of the stream:
Templates
azion create data-stream templates creates a custom template with the name and the data set you pass:
| Flag | Short | Type | Default | Description |
|---|---|---|---|---|
--active | — | string | "true" | Whether the template is active: true or false. |
--data-set | — | string | — | Path to a JSON file with the data set of the template. Use - to read the JSON from standard input. |
--file | — | string | — | Path to a JSON file with the attributes of the template. |
--name | — | string | — | Name of the template. |
--data-set takes a file path, not the JSON itself. An inline JSON string fails with this error:
The data set is a JSON object whose entries are "<key>": "$<variable>". This file, data-set.json, sends four Activity History variables:
For the variables of each data source, refer to Data sources and variables. For the data set format, refer to Templates and payload.
This command creates a template named my-template from that file:
The command prints the ID of the template:
A stream uses the template when its render_template item carries that ID, as in "template": 2996.
List
azion list data-stream takes the streams, the templates, or the data-sources subcommand. The three commands take the same flags:
| Flag | Short | Type | Default | Description |
|---|---|---|---|---|
--details | — | — | — | Adds columns to the streams list. On templates and data-sources, it adds none. |
--filter | — | string | — | Text to filter the list by. It does not narrow the templates list. |
--order-by | — | string | — | Field to sort the list by. |
--page | — | int | 1 | Number of the page to return. |
--page-size | — | int | 50 | Number of items on each page. |
Streams
azion list data-stream streams lists the streams of your account with the ID, NAME, and ACTIVE columns. --details adds the LAST EDITOR and LAST MODIFIED columns.
The command prints one row per stream:
Templates
azion list data-stream templates lists the templates of your account with the ID, NAME, and ACTIVE columns:
The command prints one row per template. The list holds the five preset templates and the custom templates of the account, such as my-template with ID 2996. The presets are Applications Event Collector (2), WAF Event Collector (4), Functions Event Collector (86), Applications + WAF Event Collector (184), and Activity History Collector (251).
--filter does not narrow this list. The command prints every template whatever the value of --filter.
Data sources
azion list data-stream data-sources lists the data sources a stream can collect from, with the SLUG, NAME, and ACTIVE columns:
The command prints one row per data source. The four data sources, by slug and name, are:
| Slug | Name |
|---|---|
activity_history | Activity History |
workloads | Workloads |
functions_console | Functions Console |
waf | WAF Events |
The slug is the value of data_source in a stream file. Azion Console labels workloads Applications and functions_console Functions.
Describe
azion describe data-stream takes the streams or the templates subcommand.
Streams
azion describe data-stream streams prints the values of one stream:
| Flag | Short | Type | Default | Description |
|---|---|---|---|---|
--stream-id | — | int | — | ID of the stream to describe. |
This command describes the stream with ID 19609:
The command prints the ID, Name, Last Editor, Modified at, Product Version, and Active fields of the stream. With --format json, it prints the full stream object, in the shape of the stream file.
Templates
azion describe data-stream templates prints the values of one template:
| Flag | Short | Type | Default | Description |
|---|---|---|---|---|
--template-id | — | int | — | ID of the template to describe. |
This command describes the template with ID 2996:
The command prints the ID, Name, Last Editor, Modified at, Custom, Active, and Data Set fields of the template. With --format json, it prints the full object: active, created_at, custom, data_set, id, last_editor, last_modified, and name. data_set is a JSON string.
Update
azion update data-stream takes the streams or the templates subcommand.
Streams
azion update data-stream streams changes the fields of a stream from a JSON file:
| Flag | Short | Type | Default | Description |
|---|---|---|---|---|
--file | — | string | — | Path to a JSON file with the fields to change. Use - to read the JSON from standard input. |
--stream-id | — | int | — | ID of the stream to update. |
The file carries only the fields to change, and the fields it leaves out keep their values. This file, stream-update.json, renames the stream:
Pass the file and the stream ID to the update command:
The command prints the ID of the updated stream:
A file that sets "active": true on a stream with a sampling item deactivates every other stream on the account.
Templates
azion update data-stream templates changes the name, the data set, or the state of a template:
| Flag | Short | Type | Default | Description |
|---|---|---|---|---|
--active | — | string | — | Whether the template is active: true or false. |
--data-set | — | string | — | Path to a JSON file with the new data set. Use - to read the JSON from standard input. |
--file | — | string | — | Path to a JSON file with the attributes to change. |
--name | — | string | — | New name of the template. |
--template-id | — | int | — | ID of the template to update. |
This command renames the template with ID 2996 to my-template-renamed:
The command prints the ID of the updated template:
Delete
azion delete data-stream takes the streams or the templates subcommand.
Streams
azion delete data-stream streams deletes a stream:
| Flag | Short | Type | Default | Description |
|---|---|---|---|---|
--stream-id | — | int | — | ID of the stream to delete. |
This command deletes the stream with ID 19609:
The command confirms the deletion:
Templates
azion delete data-stream templates deletes a custom template:
| Flag | Short | Type | Default | Description |
|---|---|---|---|---|
--template-id | — | int | — | ID of the template to delete. |
This command deletes the template with ID 2996:
The command confirms the deletion:
A template that a stream uses cannot be deleted. The command fails, and the error carries the cause ["Cannot delete a template with associated data streams."]. To delete the template, first delete the streams that use it, or update them to use another template.