Redshift data source for Grafana
The Redshift data source plugin allows you to query and visualize Redshift data metrics from within Grafana.
This topic explains options, variables, querying, and other options specific to this data source. Refer to Add a data source for instructions on how to add a data source to Grafana.
Configure the data source in Grafana
To access data source settings, hover your mouse over the Configuration (gear) icon, then click Data Sources, and then click the Amazon Redshift data source.
Authentication
For authentication options and configuration details, see AWS authentication topic.
IAM policies
Grafana needs permissions granted via IAM to be able to read Redshift metrics. You can attach these permissions to IAM roles and utilize Grafana’s built-in support for assuming roles. Note that you will need to configure the required policy before adding the data source to Grafana. You can check some predefined policies by AWS here.
Here is a minimal policy example:
{
"Version": "2012-10-17",
"Statement": [
{
"Sid": "AllowReadingMetricsFromRedshift",
"Effect": "Allow",
"Action": [
"redshift-data:ListTables",
"redshift-data:DescribeTable",
"redshift-data:GetStatementResult",
"redshift-data:DescribeStatement",
"redshift-data:ListStatements",
"redshift-data:ListSchemas",
"redshift-data:ExecuteStatement",
"redshift-data:CancelStatement",
"redshift:GetClusterCredentials",
"redshift:DescribeClusters",
"redshift-serverless:ListWorkgroups",
"redshift-serverless:GetCredentials",
"secretsmanager:ListSecrets"
],
"Resource": "*"
},
{
"Sid": "AllowReadingRedshiftQuerySecrets",
"Effect": "Allow",
"Action": ["secretsmanager:GetSecretValue"],
"Resource": "*",
"Condition": {
"Null": {
"secretsmanager:ResourceTag/RedshiftQueryOwner": "false"
}
}
}
]
}Query Redshift data
The provided query editor is a standard SQL query editor. Grafana includes some macros to help with writing more complex timeseries queries.
Macros
Table Visualization
Most queries in Redshift will be best represented by a table visualization. Any query will display data in a table. If it can be queried, then it can be put in a table.
This example returns results for a table visualization:
SELECT {column_1}, {column_2} FROM {table};Timeseries / Graph visualizations
For timeseries / graph visualizations, there are a few requirements:
- A column with a
dateordatetimetype must be selected - The
datecolumn must be in ascending order (usingORDER BY column ASC) - A numeric column must also be selected
To make a more reasonable graph, be sure to use the $__timeFilter and $__timeGroup macros.
Example timeseries query:
SELECT
avg(execution_time) AS average_execution_time,
$__timeGroup(start_time, 'hour'),
query_type
FROM
account_usage.query_history
WHERE
$__timeFilter(start_time)
group by
query_type,start_time
order by
start_time,query_type ASC;Fill value
When data frames are formatted as time series, you can choose how missing values should be filled. This in turn affects how they are rendered: with connected or disconnected values. To configure this value, change the “Fill Value” in the query editor.
Inspecting the query
Because Grafana supports macros that Redshift does not, the fully rendered query, which can be copy/pasted directly into Redshift, is visible in the Query Inspector. To view the full interpolated query, click the Query Inspector button, and the full query will be visible under the “Query” tab.
Templates and variables
To add a new Redshift query variable, refer to Add a query variable. Use your Redshift data source as your data source for the following available queries:
Any value queried from a Redshift table can be used as a variable. Be sure to avoid selecting too many values, as this can cause performance issues.
To display a custom display name for a variable, you can use a query such as SELECT hostname AS text, id AS value FROM MyTable. In this case the variable value field must be a string type or cast to a string type.
After creating a variable, you can use it in your Redshift queries by using Variable syntax. For more information about variables, refer to Templates and variables.
Annotations
Annotations allow you to overlay rich event information on top of graphs. You can add annotations by clicking on panels or by adding annotation queries via the Dashboard menu / Annotations view.
Example query to automatically add annotations:
SELECT
time as time,
environment as tags,
humidity as text
FROM
$__table
WHERE
$__timeFilter(time) and humidity > 95The following table represents the values of the columns taken into account to render annotations:
Provision Redshift data source
You can configure the Redshift data source using configuration files with Grafana’s provisioning system. For more information, refer to the provisioning docs page.
Here are some provisioning examples.
Using AWS SDK (default)
apiVersion: 1
datasources:
- name: Redshift
type: redshift
jsonData:
authType: default
defaultRegion: eu-west-2Using credentials’ profile name (non-default)
apiVersion: 1
datasources:
- name: Redshift
type: redshift
jsonData:
authType: credentials
defaultRegion: eu-west-2
profile: secondaryUsing accessKey and secretKey
apiVersion: 1
datasources:
- name: Redshift
type: grafana-redshift-datasource
jsonData:
authType: keys
defaultRegion: eu-west-2
secureJsonData:
accessKey: '<your access key>'
secretKey: '<your secret key>'Using AWS SDK Default and ARN of IAM Role to Assume
apiVersion: 1
datasources:
- name: Redshift
type: grafana-redshift-datasource
jsonData:
authType: default
assumeRoleArn: arn:aws:iam::123456789012:root
defaultRegion: eu-west-2Pre-configured Redshift dashboards
Redshift data source ships with a pre-configured dashboard for some advanced monitoring parameters. This curated dashboard is based on similar dashboards in the AWS Labs repository for Redshift. Check it out for more details.
Follow these instructions for importing a dashboard in Grafana.
Imported dashboards can be found in Configuration > Data Sources > select your Redshift data source > select the Dashboards tab to see available pre-made dashboards.
Get the most out of the plugin
- Add Annotations.
- Configure and use Templates and variables.
- Add Transformations.
- Set up alerting; refer to Alerts overview.
Async Query Data Support
Async Query Data support enables an asynchronous query handling flow. With Async Query Data support enabled, queries will be handled over multiple requests (starting, checking its status, and fetching the results) instead of having a query be started and resolved over a single request. This is useful for queries that can potentially run for a long time and timeout. You’ll need to ensure the IAM policy used by Grafana allows the following actions redshift-data:ListStatements and redshift-data:CancelStatement.
Async query data support is enabled by default in all Redshift datasources.
Async Query Caching
To enable query caching for async queries, you need to be on Grafana version 10.1 or above, and to set the feature toggles useCachingService and awsAsyncQueryCaching to true. You’ll also need to configure query caching for the specific Redshift datasource.
Plugin repository
You can request new features, report issues, or contribute code directly through the Redshift Data Source Github repository



