Use the Grafana Query Builder
View the Query Builder in Grafana by visiting the main menu and selecting “Explore.”
This will bring you to the Query Builder, which has two modes: SQL Editor and Query Builder. The Query Builder is a good way to get started with your own query. It will aid you with syntax and the timepicker placeholder variables. Later, switch to the SQL Editor to fine-tune the query.
Searching for Data
- In the Query Builder, pick your database and table. Notice how the time filter is already in place to work with the timepicker in the upper-right corner of the page. You can see this in the $__timeFilter(reqTimeSec) and similar variables in the query.
- As you’re working, periodically check the “SQL Preview” field to see the actual SQL the Query Builder is preparing to run.
- Start with a count() of rows satisfying your conditions. Once you’ve found candidate rows, pull several timestamps to discover the duration of the behavior you’re seeking.
- Finally, narrow the next query down to just that time range and pull all the fields to help you spot corresponding anomalies.
Query Debugging
When debugging queries, errors in the query will appear underneath the SQL preview. There are generally three types of errors: Grafana, ClickHouse driver, and SQL/database errors.
-
Use the query inspector to show the final version of the query before it was sent to the database. It will show you how the query was interpreted to help find bugs. You will find it in the behind the “Inspector” button below the Query Builder:
-
If you’re seeing query timeouts, that can be adjusted on the Data source. In the main menu, select “Connections,” then click “Data sources.” From there, find your ClickHouse data source that you’re currently using and adjust your query timeout setting.
Updated 1 day ago