The Snowflake Monitor configuration screen enables users to set up key account details, including account URLs, authentication keys, and user details. This configuration allows for seamless integration with Snowflake accounts for monitoring and management purposes.

## Prerequisite

To execute a query in Snowflake, the user must have the appropriate role with the required privileges. The role assigned to a user determines what actions they can perform, including querying data. You can also create a Cavisson-specific role and user to monitor Snowflake.

Execute the series of commands below in your Snowflake environment to create a user accessible for Cavisson. Steps to follow to create a new user and assign relevant privileges:

1. Create a new role intended to monitor Snowflake usage. The name of the role is customizable.
   Cmd: create role cavissonAccess
2. Grant usage to your default warehouse to the role of DATADOG.
   Cmd: grant usage on warehouse COMPUTE_WH to role cavissonAccess;
3. Grant privileges on the SNOWFLAKE database to the new role.
   Cmd: grant imported privileges on database SNOWFLAKE to role caisson access
4. Grant usage on the database schema.
   Cmd: GRANT IMPORTED PRIVILEGES on database SNOWFLAKE to role caisson access;
   Cmd: grant usage on schema SNOWFLAKE.ACCOUNT_USAGE to role cavissonaccess;
   Cmd: grant usage on schema SNOWFLAKE.ORGANIZATION_USAGE to role cavissonaccess;
5. Grant Select permission on all views inside a schema
   Cmd: GRANT SELECT ON ALL VIEWS IN SCHEMA SNOWFLAKE.ACCOUNT_USAGE TO ROLE cavissonAccess;;
   Cmd: GRANT SELECT ON ALL VIEWS IN SCHEMA SNOWFLAKE.ORGANIZATION_USAGE TO ROLE cavissonAccess;
6. Create a user.
   - CREATE USER userdemo
   - PASSWORD = 'passworddemo'
   - DEFAULT_ROLE = cavissonAccess
   - default_warehouse =COMPUTE_WH
7. Grant the monitor role to the user.
   Cmd: grant role cavissonaccess to user userdemo

## Snow Flake Configuration

- Account URL: To obtain the account URL, the user should click the link in the " Snowflake account URL or follow these steps or
  - Log In: Enter your username and password to login.
  - Locate the Bottom Left Panel:
    - Look at the bottom-left section of the interface.
    - Find an arrow button.
  - Select "Account":
    - Click the arrow button to open the menu.
    - Select "Account" from the options.
  - View Account Details:
    - Once you click on "Account", it will display account-related information, including the account name.
    - Copy Account URL: Click on the account then locate and copy the account URL.
  - Enter the Snowflake account URL in the Account URL field cavisson snowflake setting.
- User Name: The username associated with the Snowflake account will be the same user who has been granted the necessary privileges.
- Private Key: A secure private key used for authentication. You can either upload your private key or generate it via the Generate Private/Public Keys button.
- Public Key: The corresponding public key for the private key. You can either upload your private key or generate it via the Generate Private/Public Keys button.

Note: You can also create the public/private key using Snowflake instructions. Once you have generated the public key, assign it to the user via the following steps:

- Execute an ALTER USER command to assign the public key to a Snowflake user.
  Cmd: ALTER USER example_user SET RSA_PUBLIC_KEY='MIIBIjANBgkqh...';
- Verify the user,s public key fingerprint. Execute the following command to retrieve the user,s public key fingerprint:

`Cmd: DESC USER example_user;
SELECT SUBSTR((SELECT "value"
FROM TABLE(RESULT_SCAN(LAST_QUERY_ID()))
WHERE "property" = 'RSA_PUBLIC_KEY_FP'),
LEN('SHA256:') + 1);`

Note :Enable Cloud Cost Management to receive Snowflake cost metrics aggregated from the SNOWFLAKE.ORGANIZATION_USAGE.USAGE_IN_CURRENCY_DAILY table. You can use these metrics with Cloud Cost Management to gain additional insight into your cost and usage.

## Global Action Item

- Column Filter:Filter displayed columns based on your preferences.
- Manage Column:Add or remove columns as needed.

## Configuration Table

The configuration table displays all the configured Snowflake accounts and provides the following columns:

Note: User need to click add button than it will display configuration table

- Serial No:Displays the serial number of the configuration.
- Snowflake Account Name:Shows the name of the Snowflake account.
- User Name:Displays the associated username.
- Actions:
  - Delete:Remove an existing configuration.
  - Edit:Modify the details of an existing configuration.

## Monitor

- Search:Quickly search through existing configurations.
- Show Selected: View specific configurations based on your selection.
- Save:Save your configurations and monitor settings.