Create a custom template
Choose the variables each Data Stream log line carries with a custom template, then use it in a stream, in Azion Console or with the Azion API.
You can create a custom template for Data Stream from Azion Console or with the Azion API, and use it in any stream on your account. To change how a Standard HTTP/HTTPS POST endpoint joins the log lines, refer to Customize the HTTP POST payload instead.
A preset template sends every variable it carries, and you cannot change its variables. A custom template sends only the entries of its Data Set, a JSON object whose keys you name and whose values are variables of the stream’s data source. For the format, refer to Custom templates.
The examples build status-analysis, a template with five Applications variables for an analysis of response status. Replace them with the variables you need.
Prerequisites
Console
- The Edit Data Stream permission. With View Data Stream only, you can see templates and streams but not create or change them. For details, refer to Stream settings.
- The variables you want in each log line, from the data source of the stream that uses the template. For every variable and the presets that carry it, refer to Data sources and variables.
- To use the template, a stream on your account. To create one, refer to the Data Stream quickstart.
- Access to Azion Console. To sign in, refer to How to access Azion Console.
- An account with fewer than 3,000 workloads. At 3,000 workloads or more, the Console blocks the stream forms, which hold the template drawer, and you manage templates through the API only.
Create the template
The Console creates templates in a drawer of the stream form, not on a page of their own. The template belongs to the account, so every stream can use it.
Console
To create the template in Azion Console:
Access Azion Console > Data Stream.
Select + Stream, or select the row of an existing stream.
In the Render Template section, open Template and select Create Custom Template. The Create Custom Template drawer opens.
In the General section, in Name, enter status-analysis.
In the Data Set section, enter the JSON object:
The Console shows Your custom template has been created. Template lists status-analysis under Custom Templates, apart from the presets under Azion’s Templates.
To start from a preset instead, select the preset in Template, then select Duplicate Template on the Data Set field. The Create Custom Template drawer opens with the preset’s data set. Delete the entries you do not need, name the template, and select Save.
Use the template in a stream
A stream names one template. Selecting the custom template replaces the preset or template the stream used before.
Console
To use the template in a stream in Azion Console:
Access Azion Console > Data Stream, then select the row of the stream. For a stream you are creating, stay in its form.
In the Render Template section, in Template, select status-analysis under Custom Templates. The read-only Data Set field shows its entries.
If Sampling is on, the Attention dialog opens with After activating and saving these settings, all other Data Streams will be disabled. Select Confirm.
The Console shows Your data stream has been updated, or Your data stream has been created for a stream you are creating.
A stream with a workload filter, as in the API example, leaves the other streams running. Saving an active stream that uses sampling deactivates every other stream on the account.
The log lines the stream sends after the change carry only the keys of the data set, such as {"time": …, "host": …, "status": …, "request_uri": …, "upstream_status": …}. To check the delivery, read one log line at the endpoint. Each send is also recorded, with the status code the endpoint returned, in Real-Time Events.
Edit the template
To add or remove a variable on a running stream, change the data set of its custom template. A preset cannot be edited: duplicate it, then use the copy.
Console
To edit the template in Azion Console:
Access Azion Console > Data Stream, then select the row of a stream that uses the template.
In the Render Template section, select Edit Template on the Data Set field. The Edit Custom Template drawer opens.
In Data Set, add or delete entries. To also record the error status code of a request whose origin returned no response, add "proxy_status": "$proxy_status".
The Console shows Your custom template has been updated. To delete a custom template, the same drawer holds Delete template in its Danger area.