Overview
This tutorial shows how to stream telemetry from a Rust application to Sift using the Sift Stream Rust library. You will install the library, configure authentication, define telemetry signals, and send time-series data to Sift from a Rust application.Prerequisites
- Basic understanding of how Assets, Channels, and Runs relate to each other in Sift
- Working knowledge of Rust and familiarity with async programming
- A Sift API key and your Sift gRPC base URL
Scenario
Imagine a robotic vehicle that continuously reports telemetry during operation. The vehicle produces two signals: its current velocity and its internal temperature. In this tutorial, a Rust application simulates this system by generating measurements every 0.5 seconds and streaming them to Sift.Step 1: Obtain the Rust example project
Clone the Sift repository and navigate to thesift_stream crate directory, which contains the Cargo.toml file for the streaming client library and the Rust example used in this tutorial:
Step 2: Configure authentication
Create a.env file so the Rust example can authenticate with your Sift environment. Add your Sift API key and gRPC URL as environment variables:
Step 3: Run the application and view streamed data in Sift
Run the Rust example to start streaming telemetry to Sift. The example runs for about 10 minutes before stopping automatically.- From the
sift_streamdirectory (the folder containingCargo.toml), run the example: - Check the terminal for the generated Run name (for example, robot_vehicle_…_run). Then, in Sift, locate the Run name or description field and enter that name.
- In the Runs table, click the Run name.
- Click Explore.
- Click Live.
- In the Channels tab, select the following Channels:
- temperature
- velocity
Step 4: Understand the ingestion workflow
The ingestion process follows a sequence that defines the telemetry structure, establishes an ingestion session, and streams timestamped data to Sift.Authentication and streaming client initialization
-
The application begins by loading authentication credentials from the
.envfile usingdotenvy. These values are used to create aCredentialsconfiguration that allows the client to authenticate with your Sift environment. -
A streaming client is then initialized using
SiftStreamBuilder, which establishes the ingestion connection and prepares the client to send telemetry.
Telemetry schema definition
- Telemetry sent to Sift must follow a defined schema. In this example, a
FlowConfigdefines the telemetry structure, and eachChannelConfigrepresents an individual signal. - Two Channels are defined: velocity and temperature. These Channels are grouped together within a Flow named
vehicle_metrics.
Ingestion context setup
- An
IngestionConfigFormassociates the telemetry schema with an Asset and a unique client key. ARunFormthen defines the session that groups incoming telemetry. - The Run is created as part of the same streaming ingestion session initialized by
SiftStreamBuilder. This means the Run is established on the same connection used to send telemetry data.
Timestamped telemetry streaming
-
Once the ingestion context is established, the application begins generating mock telemetry values and sending them to Sift using
sift_stream.send(). Each message is sent as aFlowcontaining:- a timestamp
- the Flow name
- values for each Channel
-
After the loop completes, the program calls
finish()to ensure any queued telemetry is transmitted before the streaming session closes.