Important: This documentation is about an older version. It's relevant only to the release noted, many of the features and functions have been updated or replaced. Please view the current version.
Oracle query editor
Grafana provides a query editor for Oracle. Queries can contain macros which simplify syntax and allow for dynamic parts.
Query editor options
You can create a query directly in the query editor window. The Format as option allows you to query Oracle and return results as time series data or as a table. Click Show Help for a sample query, a list of macros and other helpful information to help you get started writing SQL queries.
Query as time series
When you set Format as to Time series
, the query must return a column called time
that returns either a SQL datetime
data type or any numeric data type representing
UNIX epoch time in seconds.
Grafana interprets DATE
and TIMESTAMP
columns without an explicit timezone as
UTC time.
Any column except time
and metric
is treated as a value column.
You can return a column named metric
that is used as metric name for the value column.
Example with metric
column:
SELECT
$__timeGroup(time_date_time, '5m') AS time,
MIN(value_double),
'MIN' as metric
FROM test_data
WHERE $__timeFilter(time_date_time)
GROUP BY $__timeGroup(time_date_time, '5m')
ORDER BY time
Query as table
When you set the Format as query option to Table
, you can create any type of SQL query. The table panel automatically shows the results of whatever columns and rows your query returns. You can change the name of a column by using the AS
SQL command, which renames the column (or table) with an alias.
Macros
To simplify syntax and to allow for dynamic parts, like date range filters, you can add macros to your query.
The plugin also supports notation using curly brackets {}
. Use this notation when queries are required inside parameters.
Note
Use one notation type per query. If the query needs braces, all macros in the query will need to use braces.
$__timeGroup{dateColumn,'5m'}
$__timeGroup{SYS_DATE_UTC(SDATE),'5m'}
$__timeGroup{FROM_TZ(CAST(SDATE as timestamp), 'UTC'), '1h'}