Overview
This guide will walk you through installing Slung, starting the server, sending events, and querying data. You’ll have a working setup in under 10 minutes.Prerequisites
Before you begin, ensure you have:- Zig compiler installed
- Nix package manager installed
- At least 1 GB of RAM
- Node.js and npm/pnpm (for the TypeScript client)
Step 1: Build and Start Slung
Build the server
Build Slung with optimizations:This creates an optimized binary in the current directory.
Step 2: Send Events with TypeScript Client
Now let’s send some events to Slung using the official TypeScript client SDK.Run the simulated stream example
Start sending simulated temperature events:This sends events every 10ms with these tags:
Step 3: Send Custom Events
You can also send custom events programmatically using the SDK.Wire Protocol: Events are encoded as little-endian binary frames:Timestamps must be Unix epoch microseconds.
Step 4: Query Your Data
Slung provides a powerful query DSL for retrieving and aggregating data.Query Syntax
Queries follow this format:- OP: Aggregation operation (AVG, SUM, MIN, MAX, COUNT) - optional
- SERIES: Series name (e.g.,
temp,cpu.usage) - TAGS: Tag filters with boolean logic (AND, OR, NOT)
- RANGE: Time range (optional) -
[start,end]in microseconds or relative units
Query Examples
Time Range Units
Supported time units for relative ranges:- s, sec, second(s): Seconds
- m, min, minute(s): Minutes
- h, hr, hour(s): Hours
- d, day(s): Days
- w, wk, week(s): Weeks
Step 5: Build a Workflow (Optional)
For advanced use cases, create custom workflows that react to events in real-time.Workflows are compiled to WebAssembly and executed by Slung’s WASM runtime. See the Workflows guide for more details.
Verify the Setup
Check that everything is working:Benchmarking
Test Slung’s performance with the built-in benchmark:Next Steps
Core Concepts
Learn about Slung’s data model and architecture
Query Syntax
Master the query DSL with advanced examples
Build Workflows
Create real-time workflows with the Rust SDK
Client SDKs
Explore the TypeScript client SDK API reference
Troubleshooting
Connection refused error
Connection refused error
Make sure the Slung server is running on port 2077:Or specify a different URL:
Build fails with Zig errors
Build fails with Zig errors
Ensure you’re using Zig 0.15.2 or higher:Use the Nix development shell for the correct version:
TypeScript client errors
TypeScript client errors
Make sure dependencies are installed:Check that the server is accepting connections: