Menu
Documentationbreadcrumb arrow Pluginsbreadcrumb arrow Oracle data sourcebreadcrumb arrow Oracle templates and variables
Enterprise Grafana Cloud

Oracle templates and variables

Instead of hard-coding details such as server, application, and sensor names in metric queries, you can use variables. Grafana lists these variables in drop-down select boxes at the top of the dashboard to help you change the data displayed in your dashboard. Grafana refers to such variables as template variables.

For instructions on how to create variables refer to Variables and Add a query variable. Use Oracle as the data source.

Read more about templates and variables in the following documentation:

Variable examples

An Oracle query returns results such as measurement names, key names or key values which are displayed as options in a drop-down select box.

Examples:

You can have a variable that contains all values for the hostname column in the host table.

sql
SELECT hostname FROM host

A query can return multiple columns and Grafana will automatically create a list from them. For example, the following query retrieves a list with values from hostname and hostname2.

sql
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, set the refresh mode of the template variable to On Time Range Change.

sql
SELECT event_name 
FROM event_log 
sWHERE $__timeFilter(time_column)

You can write a query that creates a key/value variable. The query returns two columns, one called __text and the other __value. The __text column value should be unique. If duplicates exist in __text , only the first value is used. The drop-down options display __text as the name and __value as the ID. The query below sets hostname as the text and id as the value:

sql
SELECT hostname AS __text, id AS __value 
FROM host

You can also create nested variables. You can create a variable called region, and have the hosts variable only show hosts from the current selected region with the following query:

sql
SELECT hostname 
FROM host 
WHERE region = '$region'

If region is a multi-value variable then use the IN comparison operator rather than = to match against multiple values.

Once you have created a variable, you can use it in Oracle queries by following variable syntax.

Environment variables

Note

Environment variables are not supported in Grafana Cloud.

Max response size

You can set GF_PLUGINS_ORACLE_DATASOURCE_MAX_RESPONSE_SIZE in your environment variable to change query response data size. The default is 16, the maximum is 512.

export GF_PLUGINS_ORACLE_DATASOURCE_MAX_RESPONSE_SIZE=<number>

Connection pool size

You can set GF_PLUGINS_ORACLE_DATASOURCE_POOLSIZE in your environment variable to change connection pool size. The default value is 50

export GF_PLUGINS_ORACLE_DATASOURCE_POOLSIZE=<number>