How It Works
Blocklight uses an adaptive sliding window approach that balances low latency with effective noise reduction. Aggregated findings are emitted as soon as they’re ready, not at fixed intervals.Smart Emission Strategy
Aggregated findings are emitted when:- Window elapsed + min_count reached - The configured time window has passed AND minimum detections are met
- Burst detection - 3x the
min_countis reached (immediate emission, even if window hasn’t elapsed) - Continuous monitoring - System checks every 1-5 seconds for ready aggregations
- ✅ Low latency: Findings are emitted as soon as they’re ready
- ✅ Adaptive: Burst attacks trigger immediate alerts
- ✅ Efficient: Reduces noise without sacrificing responsiveness
Aggregation Criteria
Detections are grouped when they share:- Same rule name - Must match the same detection rule
- Same chain - Must be on the same blockchain network
- Same block number - Must occur in the same block
- Within time window - Must occur within
window_seconds(default: 15 seconds)
Example: Without Aggregation
Without aggregation, a single attack pattern can generate many alerts:Example: With Aggregation
With aggregation enabled, similar detections are grouped into a single alert:Configuration
Configure aggregation inconfig.yaml:
Configuration Options
enabled- Enable or disable aggregation globallywindow_seconds- Time window for grouping detections (default: 15 seconds)- Findings are grouped if they arrive within this window from the first detection
- Aggregations are emitted as soon as the window elapses
- If 3x
min_countis reached, emission happens immediately regardless of window - Increase for higher noise reduction (e.g., 30-60 seconds)
- Decrease for more granular alerts (e.g., 5-10 seconds)
min_count- Minimum number of detections required to create an aggregation (default: 2)- Set to 3-5 for very noisy environments
- Set to 2 for balanced noise reduction
- Note: Findings below
min_countare emitted individually ifpreserve_individual: true
preserve_individual- Whether to keep individual detections accessible (default: true)- Set to
truefor forensics and detailed analysis - Set to
falseto save memory (individual detections are discarded) - Important: When
true, findings belowmin_countare still emitted as individual alerts
- Set to
Use Cases
High-Volume Monitoring
When monitoring high-traffic protocols or popular tokens, aggregation prevents alert storms:Multiple Transfers Detection
Transactions with many token transfers can generate multiple detections. Aggregation groups them:Token Transfer Monitoring
When monitoring token transfers, aggregation reduces noise from legitimate high-volume activity:Best Practices
- Start with defaults - The default configuration works well for most scenarios
- Tune based on volume - Increase
window_secondsandmin_countfor high-volume environments - Preserve individual detections - Keep
preserve_individual: truefor forensics unless memory is constrained - Monitor aggregation stats - Use the API to monitor aggregation effectiveness
- Test with dry-run - Use
blocklight dry-runto test aggregation behavior before production
Accessing Aggregated Data
Aggregated findings are available through the REST API. Individual detections remain accessible whenpreserve_individual: true. See API Reference for endpoint details.