Query examples from trivial to advanced. These showcase ROSQL's unique robotics-native features — things that would take pages of SQL, ROSQL expresses in a single line.
Start any investigation by finding which action failed. Filter the traces data source by status and action name.
FROM traces WHERE status = 'ERROR' AND action_name = '/navigate_to_pose'
The DURING() clause correlates two data sources by time. Here we find navigation failures that occurred while battery percentage was critically low — combining a trace query with a topic message query in a single statement.
SELECT trace_id, span_name, service_name, duration, status_code, span_attributes
FROM traces
WHERE status = 'ERROR' AND action_name = '/navigate_to_pose'
DURING(
FROM topics WHERE topic_name = '/battery_state'
AND fields['percentage'] < 15
)
SINCE 6 hours ago
💡 DURING() is ROSQL's most powerful feature. It replaces complex multi-table JOINs with a single, readable clause.
TRACE walks parent_span_id → span_id recursively and returns every span in the causality tree. This reveals exactly which nodes were involved and in what order — something plain SQL has no primitive for.
TRACE 'a3f1c9d2e8b04f7a'
💡 Requires ParentSpanId to be set correctly in your OTel instrumentation. See Schema Reference for details.
MESSAGE FLOW reveals which nodes published and subscribed to a given topic. Useful for understanding your robot's communication graph.
MESSAGE FLOW FROM TOPIC '/cmd_vel'
Get a real-time error rate breakdown per robot. One of five composable health queries that together replace the upcoming HEALTH() command.
SELECT COUNT(*) FROM traces WHERE status = 'ERROR' FACET robot_id SINCE 30 minutes ago
ACTION_SUCCESS_RATE() computes the fraction of succeeded action spans to total spans. Returns a value between 0 and 1 — useful for SLO tracking and alerting.
SELECT ACTION_SUCCESS_RATE('/navigate_to_pose') FROM traces SINCE 1 hour ago
TOPIC_RATE() queries the otel_metrics table for ros2.topic.message_rate values. Pass a topic name to filter to a specific topic.
SELECT TOPIC_RATE('/cmd_vel') FROM metrics SINCE 30 minutes ago
MOVING_AVG smooths out per-span latency spikes using a sliding window. Compiles to a SQL window function — no post-processing needed.
SELECT MOVING_AVG(duration, 5) FROM traces WHERE action_name = '/navigate_to_pose'
Pipeline syntax uses | to chain stages, making multi-step queries readable at a glance. Each stage filters or transforms the output of the previous one.
FROM traces
| WHERE duration > 500 ms
| WHERE status = 'ERROR'
| FACET robot_id
COMPARE TO shows current and baseline counts side by side. Instantly see if error rates are trending up or down relative to a historical baseline.
FROM traces
| WHERE action_name = '/navigate_to_pose'
| WHERE status = 'ERROR'
| FACET robot_id
| COMPARE TO last week
Ready to try these against your own data?
Quickstart →