Menu

CockroachDB query editor

Grafana provides a query editor for CockroachDB, which allows you to create and execute CockroachDB queries using SQL.

Query

Use the Query Builder to query by selecting a Table, Column and Aggregation (optional) or use the Code Editor to enter a Cockroach SQL query. Refer to Queries in Cockroach for more information on writing queries.

Macros

To simplify syntax and to allow for dynamic parts, like date range filters, the query can contain macros.

Here is an example of a query with a macro that will use Grafana’s time filter:

sql
SELECT c.date_time, c.data
FROM c
WHERE $__timeFilter(c.date_time)
  • $__timeFilter(columnName) - Replaced by a conditional that filters the data (using the provided column) based on the time range of the panel. Output example: columnName >= '2024-05-10T16:00:00Z' AND columnName <= '2024-05-10T17:00:00Z'
  • $__timeFrom(columnName) - Replaced by a conditional that filters the data (using the provided column) based on the from time of the panel. Output example: columnName >= '2024-05-10T16:00:00Z'
  • $__timeTo(columnName) - Replaced by a conditional that filters the data (using the provided column) based on the to time of the panel. Output example: columnName <= '2024-05-10T16:00:00Z'