Configure Profiler Reaction
Collect performance metrics for queries
4 minute read
The Profiler Reaction Reaction A component that receives query result changes and takes action on them. Learn more collects and reports performance metrics for queries Continuous Query A query that runs continuously, maintaining an always-current result set as data changes. Learn more . Use it to monitor query performance, identify bottlenecks, and optimize your Drasi Server Drasi Server A standalone Data Change Processing server running as a process or Docker container. Learn more deployment.
Basic Configuration
reactions:
- kind: profiler
id: query-profiler
queries: [my-query]
Configuration Reference
| Field | Type | Default | Description |
|---|---|---|---|
kind |
string | Required | Must be profiler |
id |
string | Required | Unique reaction identifier |
queries |
array | Required | Query IDs to profile |
autoStart |
boolean | true |
Start profiler automatically |
windowSize |
integer | 100 |
Number of results in metrics window |
reportIntervalSecs |
integer | 60 |
Report interval in seconds |
Metrics Collected
The profiler tracks:
| Metric | Description |
|---|---|
| Event count | Total events processed |
| Throughput | Events per second |
| Latency | Processing time per event |
| P50/P95/P99 | Latency percentiles |
| Error rate | Failed event percentage |
Window Configuration
The windowSize controls how many recent results are used for metric calculations:
reactions:
- kind: profiler
id: detailed-profiler
queries: [high-volume-query]
windowSize: 1000 # Use last 1000 results for metrics
| Use Case | Window Size |
|---|---|
| Quick feedback | 10-50 |
| Stable metrics | 100-500 |
| Trend analysis | 500-2000 |
Report Interval
Control how often metrics are reported to the Drasi Server logs:
reactions:
- kind: profiler
id: frequent-reports
queries: [critical-query]
reportIntervalSecs: 10 # Report every 10 seconds
| Use Case | Interval |
|---|---|
| Real-time monitoring | 5-15 seconds |
| General monitoring | 30-60 seconds |
| Long-term trends | 300+ seconds |
Sample Output
Profiler output in logs:
[query-profiler] ========== Profiling Report ==========
[query-profiler] Source→Query: ...
[query-profiler] Query Processing: ...
[query-profiler] Query→Reaction: ...
[query-profiler] Reaction Processing: ...
[query-profiler] Total End-to-End: ...
[query-profiler] ======================================
Use Cases
Development Profiling
Quick feedback during development:
reactions:
- kind: profiler
id: dev-profiler
queries: [test-query]
windowSize: 50
reportIntervalSecs: 10
Production Monitoring
Long-term production monitoring:
reactions:
- kind: profiler
id: production-profiler
queries: [order-query, inventory-query, customer-query]
windowSize: 500
reportIntervalSecs: 60
Performance Testing
Detailed metrics during load tests:
reactions:
- kind: profiler
id: load-test-profiler
queries: [load-test-query]
windowSize: 2000
reportIntervalSecs: 5
Multi-Query Profiling
Profile multiple queries:
reactions:
- kind: profiler
id: all-queries-profiler
queries:
- orders
- inventory
- customers
- analytics
windowSize: 200
reportIntervalSecs: 30
Complete Example
host: 0.0.0.0
port: 8080
logLevel: info
sources:
- kind: postgres
id: main-db
host: ${DB_HOST}
database: production
user: ${DB_USER}
password: ${DB_PASSWORD}
tables:
- public.orders
- public.inventory
queries:
- id: order-updates
query: "MATCH (o:orders) RETURN o"
sources:
- sourceId: main-db
- id: low-inventory
query: |
MATCH (i:inventory)
WHERE i.quantity < i.reorder_point
RETURN i
sources:
- sourceId: main-db
reactions:
# Production reactions
- kind: http
id: order-webhook
queries: [order-updates]
baseUrl: https://api.example.com
- kind: sse
id: inventory-dashboard
queries: [low-inventory]
port: 8081
# Profiler for monitoring
- kind: profiler
id: query-profiler
queries: [order-updates, low-inventory]
windowSize: 200
reportIntervalSecs: 60
Combining with Log Reaction
Use both profiler and log reactions for comprehensive debugging:
reactions:
# Debug logging
- kind: log
id: debug-log
queries: [my-query]
# Performance metrics
- kind: profiler
id: profiler
queries: [my-query]
windowSize: 100
reportIntervalSecs: 30
Interpreting Metrics
Throughput
- Low throughput: May indicate source issues or query complexity
- Variable throughput: Normal for event-driven systems
- Sudden drops: Check source connectivity
Latency
- High P99: Occasional slow events (may be acceptable)
- High P50: Consistently slow processing (investigate)
- High variance: Query complexity varies with data
Errors
- Any errors: Investigate immediately
- Increasing errors: Check source connectivity
- Pattern-based: May indicate specific data issues
Performance Tuning Guide
Based on profiler metrics:
High Latency
- Check query complexity
- Review source configuration
- Consider query optimization
- Increase server resources
Low Throughput
- Verify source is producing events
- Check query subscriptions
- Review reaction configurations
- Monitor system resources
Memory Issues
- Reduce
windowSize - Increase report interval
- Profile fewer queries
Troubleshooting
No Reports
- Verify profiler is started
- Check query is receiving events
- Review log level configuration
Inaccurate Metrics
- Increase
windowSizefor stability - Wait for enough events to accumulate
- Check for event bursts skewing metrics
High Overhead
- Increase
reportIntervalSecs - Reduce
windowSize - Profile only critical queries
Documentation resources
Profiler Reaction README
Implementation details and runtime behavior.
drasi-reaction-profiler on crates.io
Package info and release history.
Next Steps
- Operations Guide - Production operations
- Troubleshooting - Debug issues
Feedback
Was this page helpful?
Glad to hear it! Please tell us what you found helpful.
Sorry to hear that. Please tell us how we can improve.