-- Snowflake の使用状況を監視するための新しいロールを作成します。ロールの名前はカスタマイズ可能です。
create role DATADOG;-- 新しいロールに SNOWFLAKE データベースの特権を付与します。
grant imported privileges on database SNOWFLAKE to role DATADOG;-- DATADOG ロールにデフォルトのウェアハウスの使用権限を付与します。
grant usage on warehouse <WAREHOUSE> to role DATADOG;-- 以下の ACCOUNT_USAGE ビューを新しいロールに付与します。Snowflake アカウント使用状況のログやメトリクスを収集したい場合に行います。
grant database role SNOWFLAKE.OBJECT_VIEWER to role DATADOG;grant database role SNOWFLAKE.USAGE_VIEWER to role DATADOG;grant database role SNOWFLAKE.GOVERNANCE_VIEWER to role DATADOG;grant database role SNOWFLAKE.SECURITY_VIEWER to role DATADOG;-- 新しいロールに ORGANIZATION_USAGE_VIEWER を付与します。Snowflake の組織使用量メトリクスを収集したい場合に行います。
grant database role SNOWFLAKE.ORGANIZATION_USAGE_VIEWER to role DATADOG;-- 新しいロールに ORGANIZATION_BILLING_VIEWER を付与します。Snowflake のコストデータを収集したい場合に実行します。
grant database role SNOWFLAKE.ORGANIZATION_BILLING_VIEWER to role DATADOG;-- イベントテーブルのデータベース、スキーマ、およびテーブルへの使用権限を付与します。
grant usage on database <EVENT_TABLE_DATABASE> to role DATADOG;grant usage on schema <EVENT_TABLE_DATABASE>.<EVENT_TABLE_SCHEMA> to role DATADOG;grant select on table <EVENT_TABLE_DATABASE>.<EVENT_TABLE_SCHEMA>.<EVENT_TABLE_NAME> to role DATADOG;grant application role SNOWFLAKE.EVENTS_VIEWER to role DATADOG;grant application role SNOWFLAKE.EVENTS_ADMIN to role DATADOG;-- ユーザーを作成します。
create user <USERNAME>
LOGIN_NAME= <USERNAME>
password='<PASSWORD>'default_warehouse=<WAREHOUSE>
default_role= DATADOG;-- ユーザーにモニターロールを付与します。
grant role DATADOG to user <USERNAME>
キーペア認証を構成します。公開キーは先ほど作成したユーザーに割り当て、秘密キーは Datadog にアップロードし、Datadog が Snowflake アカウントに接続できるようにします。
a. Snowflake の指示に従って秘密キーを作成しアップロードします。Datadog は現在、暗号化されていない秘密キーのみをサポートしています。
b. Snowflake の指示に従って公開キーを作成します。
c. Snowflake の指示に従って先ほど作成したユーザーに公開キーを割り当てます。
Datadog が Snowflake アカウントからデータを収集するには、特定の IP アドレスプレフィックスを許可リストに登録する必要があります。Datadog に属する IP プレフィックスのリストは、IP 範囲のページで確認でき、許可する範囲は webhooks で確認できます。
-- Snowflake の使用量を監視するための新しいロールを作成します。
create role DATADOG;
-- 新しいロールに SNOWFLAKE データベースの特権を付与します。
grant imported privileges on database SNOWFLAKE to role DATADOG;
-- DATADOG ロールにデフォルトのウェアハウスの使用権限を付与します。
grant usage on warehouse <WAREHOUSE> to role DATADOG;
-- ユーザーを作成します (既存のユーザーを使用する場合はこのステップをスキップします)。
create user DATADOG_USER
LOGIN_NAME = DATADOG_USER
password = '<PASSWORD>'
default_warehouse = <WAREHOUSE>
default_role = DATADOG
default_namespace = SNOWFLAKE.ACCOUNT_USAGE;
-- ユーザーにモニターロールを付与します。
grant role DATADOG to user <USER>;
## @param account - string - required## Name of your account (provided by Snowflake), including the platform and region if applicable.## For more information on Snowflake account names,## see https://docs.snowflake.com/en/user-guide/connecting.html#your-snowflake-account-name#- account:<ORG_NAME>-<ACCOUNT_NAME>## @param username - string - required## Login name for the user.#username:<USER>## @param password - string - required## Password for the user#password:<PASSWORD>## @param role - string - required## Name of the role to use.#### By default, the SNOWFLAKE database is only accessible by the ACCOUNTADMIN role. Snowflake recommends## configuring a role specific for monitoring:## https://docs.snowflake.com/en/sql-reference/account-usage.html#enabling-account-usage-for-other-roles#role:<ROLE>## @param min_collection_interval - number - optional - default: 15## This changes the collection interval of the check. For more information, see:## https://docs.datadoghq.com/developers/write_agent_check/#collection-interval#### NOTE: Most Snowflake ACCOUNT_USAGE views are populated on an hourly basis,## so to minimize unnecessary queries, set the `min_collection_interval` to 1 hour.#min_collection_interval:3600# @param disable_generic_tags - boolean - optional - default: false# Generic tags such as `cluster` will be replaced by <INTEGRATION_NAME>_cluster to avoid# getting mixed with other integration tags.# disable_generic_tags: true
In the default `conf.yaml`, the min_collection_interval is 1 hour.
Snowflake metrics are aggregated by day, you can increase the interval to reduce the number of queries. Note: Snowflake ACCOUNT_USAGE views have a known latency of 45 minutes to 3 hours.