Official Enterprise Oracle Datasource from the Grafana team
To simplify syntax and to allow for dynamic parts, like date range filters, the query can contain macros.
Column names should normally be in uppercase, as the column name is always quoted in the query sent to Oracle. This plugin does not convert unquoted column names to uppercase.
|$__time(dateColumn)||Will be replaced by an expression to rename the column to |
|$__timeEpoch(dateColumn)||Will be replaced by an expression to rename the column to |
|$__timeFilter(dateColumn)||Will be replaced by a time range filter using the specified column name. For example, |
|$__timeFrom()||Will be replaced by the start of the currently active time selection converted to |
|$__timeTo()||Will be replaced by the end of the currently active time selection converted to |
|$__timeGroup(dateColumn,'5m')||Will be replaced by an expression usable in GROUP BY clause.|
|$__unixEpochFilter(dateColumn)||Will be replaced by a time range filter using the specified column name with times represented as unix timestamp (in milliseconds). For example, |
|$__unixEpochFrom()||Will be replaced by the start of the currently active time selection as unix timestamp. For example, |
|$__unixEpochTo()||Will be replaced by the end of the currently active time selection as unix timestamp. For example, |
The query editor has a link named
Generated SQL that shows up after a query as been executed, while in panel edit mode. Click on it and it will expand and show the raw interpolated SQL string that was executed.
Format as query option is set to
Table then you can basically do any type of SQL query. The table panel will automatically show the results of whatever columns & rows your query returns. You can control the name of the Table panel columns by using regular
as2020欧洲杯积分榜 SQL column selection syntax.
Time series queries
If you set
Format as to
Time series, for use in Graph panel for example, then the query must return a column named
time that returns either a sql datetime or any numeric datatype representing unix epoch in seconds.
Any column except
metric is treated as a value column.
You may return a column named
metric that is used as metric name for the value 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
2020欧洲杯积分榜Instead of hard-coding things like server, application and sensor name in you metric queries you can use variables in their place. Variables are shown as dropdown select boxes at the top of the dashboard. These dropdowns makes it easy to change the data being displayed in your dashboard.
If you add a template variable of the type
Query2020欧洲杯积分榜, you can write a Oracle query that can
return things like measurement names, key names or key values that are shown as a dropdown select box.
For example, you can have a variable that contains all values for the
hostname column in a table if you specify a query like this in the templating variable Query setting.
SELECT hostname FROM host
A query can return multiple columns and Grafana will automatically create a list from them. For example, the query below will return a list with values from
SELECT host.hostname, other_host.hostname2 FROM host JOIN other_host ON host.city = other_host.city
To use time range dependent macros like
$__timeFilter(column) in your query the refresh mode of the template variable needs to be set to On Time Range Change.
SELECT event_name FROM event_log WHERE $__timeFilter(time_column)
Another option is a query that can create a key/value variable. The query should return two columns that are named
__text column value should be unique (if it is not unique then the first value is used). The options in the dropdown will have a text and value that allows you to have a friendly name as text and an id as the value. An example query with
hostname as the text and
id as the value:
SELECT hostname AS __text, id AS __value FROM host
You can also create nested variables. For example if you had another variable named
region. Then you could have
the hosts variable only show hosts from the current selected region with a query like this (if
region is a multi-value variable then use the
IN comparison operator rather than
=2020欧洲杯积分榜 to match against multiple values):
SELECT hostname FROM host WHERE region IN($region)
Using Variables in Queries
2020欧洲杯积分榜From Grafana 4.3.0 to 4.6.0, template variables are always quoted automatically so if it is a string value do not wrap them in quotes in where clauses.
From Grafana 4.7.0, template variable values are only quoted when the template variable is a
If the variable is a multi-value variable then use the
IN comparison operator rather than
=2020欧洲杯积分榜 to match against multiple values.
2020欧洲杯积分榜There are two syntaxes:
$<varname> Example with a template variable named
SELECT atimestamp as time, aint as value FROM table WHERE $__timeFilter(atimestamp) AND hostname IN($hostname) ORDER BY atimestamp ASC
[[varname]] Example with a template variable named
SELECT atimestamp as time, aint as value FROM table WHERE $__timeFilter(atimestamp) AND hostname IN([[hostname]]) ORDER BY atimestamp ASC