Skip to content

Snowflake

The Snowflake provider talks to Snowflake’s SQL REST API with key-pair authentication. AVACOM needs no Snowflake driver and no password.

  • Alerts in. Snowflake alerts (CREATE ALERT) become AVACOM alerts. AVACOM reads their runs from ALERT_HISTORY every 5 minutes.

    • An alert is firing when its latest run triggered it, and high when the alert itself failed.
    • It is resolved when a later run finds its condition false. This also works when the run that triggered it is older than the history AVACOM reads, because AVACOM compares it with the state it holds.
  • Evidence out. For an incident’s users, hosts and services, AVACOM reads:

    • Each user’s logins (LOGIN_HISTORY_BY_USER), and the logins from the hosts’ client IPs.
    • Each user’s queries (QUERY_HISTORY_BY_USER), and each service’s queries, taking the service as a warehouse (QUERY_HISTORY_BY_WAREHOUSE). Only queries that failed, were queued for an overloaded warehouse, or ran at least as long as Slow query become evidence.

    They appear on the Root cause tab as snowflake.

These views are INFORMATION_SCHEMA table functions. They answer in real time for the last seven days, and show only what the role may see. Each call returns at most 10,000 rows, the newest. When a user, warehouse or client IP has more rows than that in the incident’s window, the Root cause tab says so and names the time before which that part is not seen.

What Details
Account The account identifier: orgname-accountname, or the locator with its region (xy12345.eu-central-1)
User and key A service user with an RSA public key set on it; AVACOM holds the private key
Role, warehouse, database A role that may use a small warehouse and any one database (its INFORMATION_SCHEMA answers), and may see the history
Network AVACOM reaches https://<account>.snowflakecomputing.com (or the PrivateLink host) on 443. If the account has a network policy, it allows AVACOM’s address
-- the key: openssl genrsa 2048 | openssl pkcs8 -topk8 -nocrypt -out rsa_key.p8
-- openssl rsa -in rsa_key.p8 -pubout -out rsa_key.pub
CREATE ROLE AVACOM_MONITOR;
CREATE WAREHOUSE AVACOM_WH WAREHOUSE_SIZE = XSMALL AUTO_SUSPEND = 60 AUTO_RESUME = TRUE INITIALLY_SUSPENDED = TRUE;
GRANT USAGE ON WAREHOUSE AVACOM_WH TO ROLE AVACOM_MONITOR;
GRANT USAGE ON DATABASE OPS TO ROLE AVACOM_MONITOR;
GRANT MONITOR ON ACCOUNT TO ROLE AVACOM_MONITOR; -- everyone's logins and queries
GRANT MONITOR EXECUTION ON ACCOUNT TO ROLE AVACOM_MONITOR; -- every alert's runs
CREATE USER SVC_AVACOM TYPE = SERVICE DEFAULT_ROLE = AVACOM_MONITOR DEFAULT_WAREHOUSE = AVACOM_WH
RSA_PUBLIC_KEY = 'MIIBIjANBgkqh...'; -- rsa_key.pub without its header lines
GRANT ROLE AVACOM_MONITOR TO USER SVC_AVACOM;

Without MONITOR, the history quietly shows only the service user’s own logins and queries. Your security team may prefer narrower grants, such as MONITOR on the warehouses that matter.

Every alert pull and every RCA runs statements on the warehouse, and resumes it when it is suspended. Snowflake bills at least 60 seconds each time a warehouse resumes. With a pull every 5 minutes, an X-Small warehouse that suspends after 60 seconds runs for about 12 minutes an hour. Use a warehouse of its own, X-Small, with AUTO_SUSPEND = 60. To pull less often, set AVACOM_SNOWFLAKE_PULL_MINUTES (for example 15) on AVACOM’s API and its workers. It applies to every Snowflake provider of the installation.

  1. In AVACOM, open Providers, choose Snowflake and fill in:

    Field Value
    Snowflake user, account identifier As above
    Snowflake private key (PEM) The contents of rsa_key.p8; a passphrase only if the key is encrypted
    Warehouse, role, database AVACOM_WH, AVACOM_MONITOR, OPS; empty means the user’s defaults, but alerts and evidence need a database
    Host Only for PrivateLink: a *.snowflakecomputing.com host, over https. Any other host must be listed in AVACOM_OUTBOUND_ALLOWED_HOSTS
    Alert history to read, slow query, statement timeout 24 hours, 60 seconds, 60 seconds by default
  2. Turn on Pulling Enabled for its alerts.

  3. Press Connect. AVACOM signs in and checks each permission with statements of its own:

    • Connect: the session has the role, warehouse and database you named.
    • Alert history: the role may read ALERT_HISTORY, and holds MONITOR EXECUTION on the account itself.
    • Login history, Query history: the role may read each one, and either holds MONITOR on the account itself or sees another user’s rows from the last six days.

    A check that passes only for the user’s own rows reads Limited, with the grant that is missing. A grant that comes through another role cannot be seen this way. If the evidence shows other users’ rows, the role has what it needs.

A workflow step can run SQL on Snowflake. Values go in as bound parameters, never into the SQL text:

- name: open-orders
provider:
type: snowflake
config: "{{ providers.snowflake }}"
with:
query: "SELECT STATUS, COUNT(*) AS N FROM PAYMENTS.CORE.ORDERS WHERE HOST = ? GROUP BY STATUS"
parameters: ["{{ alert.host }}"]
  • Rows come back as lists of values in column order, as before: {{ steps.open-orders.results.0.1 }} is the first row’s N. Add as_dict: true to get them by column name (results.0.N). Columns must then have different names (alias them with AS).
  • Values. Numbers with decimals come back as exact decimals, timestamps in UTC.
  • Size and time. A step returns at most 10,000 rows. Set max_rows (up to 100,000) for more or fewer. The whole statement, including fetching a large result, must finish within the provider’s statement timeout.
  • Older steps that wrote {table} placeholders filled by query.format are refused: write ? and pass parameters. A string in place of the parameters list is refused too.