Send Data Stream data to Object Storage
Point a Data Stream stream at an Object Storage bucket through the S3 endpoint, in Azion Console or with the Azion API, and confirm the delivery.
You can send the logs of a stream to an Object Storage bucket from Azion Console or with the Azion API. To create a stream that writes to a bucket from the start, refer to the Data Stream quickstart. To send the logs to an Amazon S3 bucket, refer to Send logs to Amazon S3.
Data Stream reaches the bucket through the S3 endpoint and writes each batch of log lines as one object. In the stream form, the endpoint is set in the field labeled Connector, and its option is Simple Storage Service (S3). For every field and its bounds, refer to Endpoints.
Select your interface once. The prerequisites and every task below show only that path.
Prerequisites
- The Edit Data Stream permission. For the permissions, refer to Stream settings.
- A stream on the account. To create one, refer to the Data Stream quickstart.
- An Object Storage bucket. To create one, refer to the Object Storage quickstart.
- An Object Storage credential that reaches the bucket, with four capabilities: List Files, Write Files, List All Bucket Names, and List Buckets. In the API, these are
listFiles,writeFiles,listAllBucketNames, andlistBuckets. Without the two bucket-list capabilities, every send fails with status503, and no object reaches the bucket. The secret key shows only once, when the credential is created. To create the credential, refer to S3 protocol compatibility credentials.
- Access to Azion Console. To sign in, refer to How to access Azion Console.
Point the stream at the bucket
The stream keeps its data source, its filters, and its template. Only the endpoint changes, with the bucket’s S3 address, its region, and the key pair of the credential.
To point the stream at the bucket with the API, send a PATCH request with the outputs key only. Replace <stream-id> with the ID of your stream, <your-bucket> with the name of your bucket, and the two keys with the keys of your credential:
The API answers 200 with the stored stream:
The outputs entry holds the bucket, and last_modified moves forward. The data source and the transforms stay as they were. For every key of the body, refer to Stream settings.
Saving checks the format of each field and does not contact the bucket. A wrong key or a missing capability shows only as a failed send. An activation takes effect after one to two minutes. If the stream uses sampling, saving it as active deactivates every other stream on the account; a workload filter leaves them active.
Confirm the delivery
A stream sends a batch every 60 seconds, or sooner when it reaches 2,000 log lines. Two checks confirm the delivery: the object in the bucket, and the send that Real-Time Events records.
Find the object in the bucket
Each object name is the Object Key Prefix, a /, the date and time of the send in the YYYY/MM/DD/hh/mm/ format, and a UUID. Data Stream adds the / after the prefix.
To list the objects in the bucket with the API, send a GET request to the bucket. Replace <your-bucket> with the name of your bucket:
The API answers 200 with one entry per object, each with its key, its time, and its size in bytes:
The key starts with the prefix activity, followed by the date and time of the send, which confirms that the stream delivered a batch.
Read the send in Real-Time Events
Real-Time Events records every send of a stream, delivered or not, with the status code the endpoint returned.
To read the sends with the API, query the dataStreamedEvents dataset of the Real-Time Events GraphQL API. Replace the dates with a range that covers the change of the stream:
The API answers 200 with one record for each send, the latest first:
A statusCode of 200 means the bucket accepted the batch, and streamedLines and dataStreamed give its size in log lines and bytes. An empty dataStreamedEvents list means the stream has not sent in the range. For every field, refer to Real-Time Events GraphQL fields.
An object under the prefix and a send with status 200 together confirm the delivery. A status of 503 means Data Stream found the endpoint unavailable. With Object Storage, check first that the credential carries listAllBucketNames and listBuckets. For the causes, refer to Troubleshoot Data Stream.