Snowflake

Data SourceENTERPRISE

Snowflake Datasource for Grafana
Enterprise

Enterprise plugins, along with support and assistance from the core team behind Grafana, are available with Grafana Enterprise.

Please sign up or log in to get started.

Sign Up
  • Example Dashboard
    Example Dashboard
  • Query Editor
    Query Editor
  • Datasource Configuration
    Datasource Configuration

Snowflake Plugin

Maintainability Test Coverage

Plugin to monitor and visualize data from Snowflake

Table of contents

Features

  • Timeseries Visualizations
  • Table Visualizations
  • Alerting on Query Results
  • Autocompletion SQL Query Editor
  • Error handling for SQL Query
  • Variables for Queries
  • Annotations
  • Multi Metric Queries

Add Datasource

NameDescription
AccountAccount for snowflake
UsernameUsername for the service account
PasswordPassword for the service account
SchemaSets a default schema for queries
WarehouseSets a default warehouse for queries
DatabaseSets a default database for queries
RoleAssumes a role for queries

Query Editor

NameDescription
SQL EditorSmart Autocompletion SQL Editor
Format AsFormat data to timeseries or table

Alerting

Click on the alert tab button and click create alert

Autocompletion

Autocompletion for basic sql query keywords

Error Handling

Error handling for Sql Query Syntax

Variables for Queries

Variables for Queries

Multi Metric Queries

Onboarding

In order for this plugin to support your Snowflake query, the query must the following formats:

SQL Query Format For Timeseries

  1. Date / time can appear anywhere in the query as long as it is included.
  2. A numerical column must be included. This can be an aggregation or an int/float column.
  3. Optionally, you can include string columns to create separate data series, if your timeseries data is formatted for different metrics.
select
  <time_column>,
  <any_numerical_column>
  <other_column_1>,
  <other_column_2>,
  <...>
from
  <any_table>
where
  $__timeFilter(<time_column>) // predefined where clause for time range
  and $<custom_variable> = 1 // custom variables start with dollar sign

SQL Query Format For Timeseries Group By Interval

select
  $__timeGroup(created_ts, '1h'), // group time by interval of 1h
  <time_column>, 
  <any_numerical_column>,
  <metric_column>
from
  <any_table>
where
  $__timeFilter(<time_column>) // predefined where clause for time range
  and $<custom_variable> = 1 // custom variables start with dollar sign
group by <time_column>

SQL Query Format For Tables

select
  <time_column>, // optional if result format option is table
  <any_column_1>
  <any_column_2>
  <any_column_3>
from
  <any_table>
where
  $__timeFilter(time_column) // macro for time range, optional if format as option is table
  and $<custom_variable> = 1 // custom variables start with dollar sign

Variables

Using variables

Simply add a variable in your query:

select
  <column>
from 
  <table>
WHERE <column> = '$variable'

Using multi-value variables

Multi-value variables can be used in query with the regexp operator.

select
  <column>
from 
  <table>
WHERE <column> regexp '${variable:regex}'

Using the Snowflake datasource to create variables

In the dashboard settings, click "Variables", and "New".

Using the "Query" variable type, select the Snowflake datasource as the "Datasource".

Be sure to only select 1 column in your variable query

Example:

SELECT DISTINCT query_type from account_usage.query_history;

will give you these variables:

All DESCRIBE USE UNKNOWN GRANT SELECT CREATE DROP SHOW

Annotations

Annotations allow users to overlay events on a graph.

To create an annotation, in the dahboard settings click "Annotations", and "New", and select Snowflake as the datasource.

Because annotations are events, they require at least 1 time column and 1 column to describe the event.

Example query to annotate all failed logins to Snowflake:

SELECT
  EVENT_TIMESTAMP as time,
  EVENT_TYPE,
  CLIENT_IP
FROM ACCOUNT_USAGE.LOGIN_HISTORY
WHERE $__timeFilter(time) AND IS_SUCCESS!='YES'
ORDER BY time ASC;

And

  • time: TIME
  • title: EVENT_TYPE
  • text: CLIENT_IP

This will overlay annotations of all failed logins to snowflake on your dashboard panels.

Aliasing

Using Display Name

This plugin uses the Display Name field in the Field tab of the Options panel (available in Grafana v7.0+) to shorten or alter a legend key based on its name, labels, or values. Other datasources use custom alias functionality to modify legend keys, but the Display Name function is a more consistent way to do so. Documentation for the Display Name field option is in the Grafana docs.

Display name altering legend keys

Development

Installation

# Clone project
git clone https://github.com/grafana/snowflake-datasource.git

# Install dependencies
yarn install

Build

# Watch for changes and build the frontend
yarn watch
# With grafana running
mage buildAll && mage reloadPlugin
Sign up Now

Version

Includes:
  • Snowflake Billing & Usage

Dependencies:
  • Grafana 7.2.x