Analytics
SuiPulse provides powerful analytics capabilities for monitoring and analyzing your data streams.
Overview
Analytics in SuiPulse helps you:
- Monitor stream performance
- Track usage patterns
- Analyze data trends
- Optimize resource usage
Event Monitoring
Stream Events
import { SuiPulse, Network } from "@suipulse/sdk";
import { Ed25519Keypair } from "@mysten/sui.js/keypairs/ed25519";
// Initialize SuiPulse
const keypair = Ed25519Keypair.fromSecretKey(/* your private key */);
const suiPulse = new SuiPulse(keypair, Network.MAINNET);
// Monitor stream creation events
const unsubscribe = await suiPulse.subscribeToEvents(
"StreamCreated",
(event) => {
console.log("New stream created:", event.parsedJson.stream_id);
}
);
// Monitor stream update events
const unsubscribe = await suiPulse.subscribeToEvents(
"StreamUpdated",
(event) => {
console.log("Stream updated:", event.parsedJson.stream_id);
}
);
Snapshot Events
// Monitor snapshot creation events
const unsubscribe = await suiPulse.subscribeToEvents(
"SnapshotCreated",
(event) => {
console.log("New snapshot created:", event.parsedJson.snapshot_id);
}
);
Data Analysis
Stream Data Analysis
// Get stream data
const streamData = await suiPulse.getDataStream(streamId);
console.log("Stream data:", streamData);
// Get snapshot data
const snapshotData = await suiPulse.getSnapshotData(snapshotId);
console.log("Snapshot data:", snapshotData);
Best Practices
-
Monitoring
- Track key metrics
- Set up alerts
- Monitor resource usage
-
Performance
- Optimize data structures
- Use batch operations
- Implement caching
-
Analysis
- Plan data retention
- Use appropriate tools
- Document insights
Use Cases
- Performance monitoring
- Usage analytics
- Trend analysis
- Resource optimization
- Capacity planning
Next Steps
- Learn about Data Streams
- Explore Snapshots
- Check out Access Control