Skip to main content

Running the Snowflake collector on-premise

Note

The latest version of the Collector is 2.200. To view the release notes for this version and all previous versions, please go here.

Generating the command or YAML file

This section walks you through the process of generating the command or YAML file for running the collector from Windows or Linux or MAC OS.

To generate the command or YAML file:

  1. On the Organization profile page, go to the Settings tab > Metadata collectors section.

  2. Click the Add a collector button.

    add_a_collector.png
  3. On the Choose metadata collector screen, select the correct metadata source. Click Next.

  4. On the Choose where the collector will run screen, in the On-premise section, select if you will be running the collector on Windows or Mac OS or Linux. This will determine the format of the YAML and CLI that is generated in the end. Click Next.

    select_an_os.png
  5. On the On-prem collector setup prerequisites screen, read the pre-requisites and click Next.

  6. On the Configure an on-premises Snowflake Collector screen, set the following properties and click Next.

  7. On the next screen, set the following properties and click Next.

    Important

    Snowflake is case-sensitive so database and schema names need to be specified with the same case as they are in Snowflake.

    Table 2.

    Field name

    Corresponding parameter name

    Description

    Required

    Server

    -s=<server>

    --server=<server> 

    The hostname of the database server to connect to.

    Yes

    Server port

    -p=<port>

    --port=<port>

    The port of the database server (if not the default).

    No

    Database

    -d=<database>

    --database=<database>

    The name of the database to connect to.

    Yes

    Snowflake role

    -r=<role>

    --role=<role>

    The role used to execute the query.

    Yes

    Authentication

    Select from one of the following options:

    • Authenticate with a username & password

    • Authenticate using a private key file

    Yes

    Authenticate with a username & password

    Username

    -u=<user>

    --user=<user>

    The username used to connect to the database.

    Yes

    Password

    -P=<password>

    --password=<password> 

    The environment variable of the password used to connect to the database. Default value is an environment variable ${DW_SNOWFLAKE_PASSWORD}

    Yes

    Authenticate using a private key file

    Username

    -u=<user>

    --user=<user>

    Specify the username to use to make the JDBC connection.

    Yes

    Private key file path

    --private-key-file=<PrivateKeyFile>

    The private key file to use for authentication. You will need to mount a local directory containing the private-key-file with a directory on the Docker container. The --private-key-file should be the path to the directory on the container with the private key. For instance, for a private-key-file called rsa_key.p8, add to the CLI command --mount type=bind,source=/tmp,target=/snowflake-key and set --private-key-file="/snowflake-key/rsa_key.p8"

    Yes

    Private key file password

    --private-key-file-password=<PrivateKeyFilePassword>

    The password for the private key file, if the key is encrypted and a password was set. Default value is an environment variable ${DW_SNOWFLAKE_PK_PASSWORD}.

    No

    Schemas to collect

    Select from one of the following options: Collect all schema, Specify which schema to collect

    Yes

    Collect all schema

    -A

    --all-schemas

    Catalog all schemas to which the user has access.

    Yes

    (if --schema is not set)

    Specify which schema to collect

    -S=<databaseSchema>

    --schema=<databaseSchema>

    Select this option and then specify the names of the database schema to be catalog.

    Yes

    (if --all-schemas is not set)

    Information schema

    --include-information-schema

    Set this if you want to also collect this Information schema for the database. You can set this option only when you have selected the Collect all schema (--all-schemas) option.

    No



  8. On the next screen, set the following optional properties and click Next.

    Table 3.

    Field name

    Corresponding parameter name

    Description

    Required?

    Disable lineage collection

    --disable-lineage-collection

    Skip harvesting of intra-database lineage metadata.

    No

    Collect Snowflake tag information

    --tag-collection

    Harvest information about Snowflake tags

    No

    Enable sample string values collection

    --sample-string-values

    To enable harvesting of sample values and histograms for columns containing string data.

    No

    Collect Snowflake policy information

    --policy-collection

    Harvest information about Snowflake masking and row-access policies

    No

    Collect data metric function information

    --data-metric-function-collection

    Specify to harvest metadata about data metric functions and their associations to tables.

    No

    Number of most recent data metric observations to harvest

    --data-metric-observation-count=<dataMetricObservationCount>

    Specify to indicate the number of most recent data metric observations to harvest. default is 1

    Ignored unless --data-metric-function-collection is set.

    No

    Collect Snowflake table usage information

    --table-usage-collection

    Harvests metadata about Snowflake table usage in queries (popularity). Calculates, for each table in the database being harvested, the percentage of tables in the database that have been queried no fewer times than the subject table.

    No

    Table usage lookback days

    --table-usage-lookback

    Number of days in the past at which to begin harvesting table usage (default=7 days).

    No

    Enable column statistics collection

    --enable-column-statistics

    To enable harvesting of column statistics (i.e., data profiling).

    Note: Activating the profiling feature may extend the running time of the collector. This is because the collector needs to read the table data to be able to gather metadata for profiling.

    No

    Target sample size for Profiling

    --target-sample-size=<targetSampleSize>

    To control the number of rows sampled for computation of column statistics and string-value histograms. For example, to sample 1000 rows, set the parameter as: --target-sample-size=1000

    No

    Snowflake warehouse

    -w=<warehouse>

    --warehouse=<warehouse>

    The Snowflake warehouse to use when connecting (user's assigned default if not specified)

    No

    Server environment

    -e=<environment>

    --environment=<environment>

    If your provided server name is localhost, use this to give a friendly name to the environment in which your database server runs. It helps differentiate it from other environments.

    No

    Database ID

    -D=<databaseId>

    --database-id=<databaseId>

    A unique identifier for this database - will be used to generate the ID for the database. This is optional, you only need to provide this if the database name used for the connection is not sufficiently unique to completely identify the database.

    No

    JDBC Properties

    --jdbc-property=<driverProperties> 

    JDBC driver properties to pass through to driver connection.

    No



  9. On the next screen, provide the Collector configuration name. This is the name used to save the configuration details. The configuration is saved and made available on the Metadata collectors summary page from where you can edit or delete the configuration at a later point. Click Save and Continue.

  10. On the Finalize your Snowflake Collector configuration screen, you are notified about the environment variables and directories you need to setup for running the collector. Select if you want to generate a Configuration file( YAML) or Command line arguments (CLI). Click Next.

    Important

    You must ensure that you have set up these environment variables and directories before you run the collector.

  11. The next screen gives you an option to download the YAML configuration file or copy the CLI command. Click Done. If you are generating a YAML file, click Next.

  12. The Snowflake command screen gives you the command to use for running the collector using the YAML file.

  13. You will notice that the YAML/CLI has following additional parameters that are automatically set for you.

    Important

    Except for the collector version, you should not change the values of any of the parameter listed here.

    Table 4.

    Parameter name

    Details

    Required?

    -a= <agent>

    --agent= <agent>

    --account= <agent>

    The ID for the data.world account into which you will load this catalog - this is used to generate the namespace for any URIs generated.

    Yes

    --site= <site>

    This parameter should be set only for Private instances. Do not set it for public instances and single-tenant installations. Required for private instance installations.

    Yes (required for private instance installations)

    -U

    --upload

    Whether to upload the generated catalog to the  organization account's catalogs dataset.

    Yes

    -L

    --no-log-upload

    Do not upload the log of the Collector run to the organization account's catalogs dataset.

    Yes

    dwcc: <CollectorVersion>

    The version of the collector you want to use (For example, datadotworld/dwcc:2.168)

    Yes



  14. Add the following additional parameter to test run the collector.

    • --dry-run: If specified, the collector does not actually harvest any metadata, but just checks the database connection parameters provided by the user and reports success or failure at connecting.

  15. You can add the following parameter to the command/YAML file to use these additional features.

    Table 5.

    Parameter name

    Details

    Required?

    --exclude-database=<excludedDatabaseRegexes>

    When the --database parameter is not provided in the command/YAML file, the collector harvests metadata from all databases. If you want the collector run to not harvest specific databases, use the --exclude-database parameter and specify one or more regular expressions to indicate databases not to be cataloged.

    This parameter is ignored if the --database is specified.

    No

    --streamlit-app-collection

    Harvest information about Snowflake Streamlit applications.

    No



Verifying environment variables and directories

  1. Verify that you have set up all the required environment variables that were identified by the Collector Wizard before running the collector. Alternatively, you can set these credentials in a credential vault and use a script to retrieve those credentials.

  2. Verify that you have set up all the required directories that were identified by the Collector Wizard.

Running the collector

Important

Before you begin running the collector make sure you have completed the pre-requisite tasks.

Running collector using YAML file

  1. Go to the machine where you have setup docker to run the collector.

  2. Place the YAML file generated from the Collector wizard to the correct directory.

  3. From the command line, run the command generated from the application for executing the YAML file.

    Caution

    Note that is just a sample command for showing the syntax. You must generate the command specific to your setup from the application UI.

    docker run -it --rm --mount type=bind,source=${HOME}/dwcc,target=/dwcc-output \
      --mount type=bind,source=${HOME}/dwcc,target=${HOME}/dwcc --mount type=bind,source=${HOME}/dwcc-drivers,target=/usr/src/dwcc-config/lib \
      -e DW_AUTH_TOKEN=${DW_AUTH_TOKEN} -e DW_SNOWFLAKE_PASSWORD=${DW_SNOWFLAKE_PASSWORD} \
      datadotworld/dwcc:2.124 --config-file=/dwcc-output/config-snowflake.yml
  4. The collector automatically uploads the file to the specified dataset and you can also find the output at the location you specified while running the collector.

  5. If you decide in the future that you want to run the collector using an updated version, simply modify the collector version in the provided command. This will allow you to run the collector with the latest version.

Running collector without the YAML file

  1. Go to the machine where you have setup docker to run the collector.

  2. From the command line, run the command generated from the application. Here is a sample command.

    Caution

    Note that is just a sample command for showing the syntax. You must generate the command specific to your setup from the application UI.

    docker run -it --rm --mount type=bind,source=${HOME}/dwcc,target=/dwcc-output \
      --mount type=bind,source=${HOME}/dwcc,target=${HOME}/dwcc --mount type=bind,source=${HOME}/dwcc-drivers,target=/usr/src/dwcc-config/lib \
      datadotworld/dwcc:2.124 catalog-snowflake --agent=8bank-catalog-sources \
      --site=solutions --no-log-upload=false --upload=true --api-token=${DW_AUTH_TOKEN} \
      --output=/dwcc-output --name=8bank-catalog-sources-collection \
      --upload-location=ddw-catalogs --server=cu440.snowflakecompu.com \
      --database=SAMPLE_DB --user=catalogstudent1 --password=${DW_SNOWFLAKE_PASSWORD} \
      --all-schemas=true --include-information-schema=false --policy-collection=true \
      --tag-collection=true --disable-lineage-collection=true --enable-column-statistics=true \
      --sample-string-values=false
  3. The collector automatically uploads the file to the specified dataset and you can also find the output at the location you specified while running the collector.

  4. If you decide in the future that you want to run the collector using an updated version, simply modify the collector version in the provided command. This will allow you to run the collector with the latest version.

Automating updates to your metadata catalog

Maintaining an up-to-date metadata catalog is crucial and can be achieved by employing Azure Pipelines, CircleCI, or any automation tool of your preference to execute the catalog collector regularly.

There are two primary strategies for setting up the collector run times:

  • Scheduled: You can configure the collector according to the anticipated frequency of metadata changes in your data source and the business need to access updated metadata. It's necessary to account for the completion time of the collector run (which depends on the size of the source) and the time required to load the collector's output into your catalog. This could be for instance daily or weekly. We recommend scheduling the collector run during off-peak times for optimal performance.

  • Event-triggered: If you have set up automations that refresh the data in a source technology, you can set up the collector to execute whenever the upstream jobs are completed successfully. For example, if you're using Airflow, Github actions, dbt, etc., you can configure the collector to automatically run and keep your catalog updated following modifications to your data sources.

Managing collector runs and configuration details