Configure sampling on a stream
Send a share of a stream's events with Data Stream sampling, in Azion Console or with the Azion API, and check which streams stay active.
You can configure sampling on a Data Stream stream from Azion Console or with the Azion API. To limit a stream to the workloads you choose, which leaves the other streams active, refer to Associate workloads with a stream instead.
Sampling sends a percentage of the events a stream collects, picked at random. A lower rate reduces the volume, and the cost, of the data you collect and analyze. A stream with sampling covers every workload on the account, including workloads created later. For the bounds of each field, refer to Stream settings.
Select your interface once. The prerequisites and every task below show only that path.
Prerequisites
- A stream on your Azion account. To create one, refer to the Data Stream quickstart.
- The Edit Data Stream permission. For details, refer to Stream settings.
- Access to Azion Console. To sign in, refer to Access Azion Console.
- An account with fewer than 3,000 workloads. At 3,000 workloads or more, the Console blocks the stream forms, and you manage streams through the API only.
Set the sampling rate
The rate is a whole number from 1 to 100: the percentage of events the stream sends. A rate of 100 sends every event, and it still counts as sampling.
To set the rate with the API, send a PATCH request with the transform array of the stream. Set rate in the sampling item, and keep the render_template item with the template ID of your stream. This example keeps template 2, Applications Event Collector. Replace <stream-id> with the ID of your stream:
The API answers 200 with the stream, which now carries the new rate:
The transform you send replaces the stored one, so send every item the stream keeps. A rate outside 1 to 100 is refused with 400: 0 with 10050 Min Value, and 101 with 10068 Max Value. A valid rate returns no warning that the other streams are deactivated.
Data Stream picks the sampled events at random. The Attention dialog also states Sampling percentage is statistical and not absolutely precise. When multiple Data Streams have different sampling rates, the system uses the lowest percentage.
A change of active stream takes effect after one to two minutes, and other edits take a few minutes to propagate. During that window, a stream that the save deactivated can keep sending.
Check which streams are active
After the save, the stream with sampling is the only active stream on the account. Wait two minutes, then check the status of each stream.
To check the streams with the API, list them with their active state and their transform:
The API answers 200 with one entry for each stream:
The stream saved last with sampling is the only one with "active": true, such as 12346 in the sample above. Its sampling item carries the rate it uses.
To see what the stream sends, read its sends in Real-Time Events. Each send is recorded with the status code of the endpoint and the number of log lines it carried.