Skip to content

Snowflake Query Audit Logs

Snowflake query audit logs is a feature that audits queries that users run natively in Snowflake and presents them in a universal format as Immuta audit logs. Immuta uses the Snowflake QUERY_HISTORY and ACCESS_HISTORY tables and translates them into the audit logs that can be viewed at query events in the Immuta UI or exported to S3. Immuta audits the activity of Immuta users on Immuta data sources.

Requirements

Best practices: Store audit logs

By default most Immuta audit logs expire after 90 days. Export the universal audit model (UAM) logs to S3, and store audit logs outside of Immuta in order to retain the audit logs long-term.

Audit frequency

Immuta collects audit records at the frequency configured when enabling the integration, which is between 1 and 24 hours. The frequency is a global setting based on integration type, so organizations with multiple Snowflake integrations will have the same audit frequency for all of them. The more frequent the audit records are ingested, the more current the audit records; however, there could be performance and cost impacts from the frequent jobs.

To manually request native query audit ingestion, click Load Audit Events on the Immuta audit page.

Audit schema

Each audit message from the Immuta platform will be a one-line JSON object containing the properties listed below.

Property Description Example
action The action associated with the audit log. QUERY
actor.type The Immuta user type of the actor who made the query. USER_ACTOR
actor.id The Immuta user ID of the actor who made the query. taylor@snowflake.com
actor.name The Immuta name of the user who made the query. Taylor
actor.identityProvider The IAM the user is registered in. bim is the built-in Immuta IAM. bim
sessionId The session ID of the user who performed the action. 01ee14d9-cab3-1ef6-9cc4-f0c315a53788
actionStatus Indicates whether or not the user was granted access to the data. Possible values are UNAUTHORIZED, FAILURE, or SUCCESS. SUCCESS
actionStatusReason When available, the reason from Unity Catalog that the user’s query was denied. null if actionStatus is SUCCESS
eventTimestamp The time the query occurred. 2023-06-27T11:03:59.000Z
id The unique ID of the audit record. 9f542dfd-5099-4362-a72d-8377306db3b8
tenantId The Immuta SaaS tenant ID. your-immuta.com
targetType The type of targets affected by the query; this value will always be DATASOURCE. DATASOURCE
targets A list of the targets affected by the query. See the example below
auditPayload.type The type of audit record; this value will always be: QueryAuditPayload. QueryAuditPayload
auditPayload.queryId The unique ID of the query. If the query joins multiple tables, each table will appear as a separate log, but all will have the same query ID. 01ee14da-517a-1670-afce-0c3e0fdcf7d4
auditPayload.query The command text of the query that was run in the integration. SELECT VERSION AS 'version' FROM 'sample-data'.'__immuta_version'
auditPayload.startTime The date and time the query started in UTC. 2023-06-27T11:03:59.000Z
auditPayload.duration The time the query took in seconds. 0.557
auditPayload.errorCode The errorCode for the denied query. null if actionStatus is SUCCESS
auditPayload.technologyContext.type The technology the query was made in. SnowflakeContext
auditPayload.technologyContext.host The host that the integration is connected to. your-hostname.snowflake.computing.com
auditPayload.technologyContext.snowflakeUsername The user's Snowflake username. taylor@snowflake.com
auditPayload.technologyContext.rowsProduced The number of rows returned in the query. Note that rows produced will show 0 for cached queries. 3
auditPayload.objectsAccessed The Snowflake objects accessed with details on the columns returned and the tags on those columns. []
auditPayload.securityProfile.sensitivity.score The sensitivity score of the query. Classification must be configured for this field. INDETERMINATE
receivedTimestamp The timestamp of when the audit event was received and stored by Immuta. 2023-06-27T15:18:22.314Z

Example audit record

{
  "action": "QUERY",
  "actor": {
    "type": "USER_ACTOR",
    "name": "Taylor",
    "id": "taylor@snowflake.com",
    "identityProvider": "immuta",
    "impersonatedBy": null
  },
  "sessionId": "18245308848957358",
  "actionStatus": "SUCCESS",
  "actionStatusReason": null,
  "eventTimestamp": "2023-03-21T13:39:45.040598-04:00",
  "id": "abcd",
  "tenantId": "your-immuta.com",
  "targetType": "DATASOURCE",
  "targets": [
    {
      "type": "DATASOURCE",
      "id": "2034",
      "name": "University Art Gallery Exhibition",
      "technology": "SNOWFLAKE"
    }
  ],
  "relatedResources": [],
  "auditPayload": {
    "type": "QueryAuditPayload",
    "queryId": "01a9c8f5-0602-eeb3-0040-d203014c166a",
    "query": "SELECT T2.theme ,  T1.date ,  T1.attendance FROM \"DETECT_DEMO_DB\".\"UNIVERSITY_ART_GALLERY\".\"EXHIBITION_RECORD\" AS T1 JOIN \"DETECT_DEMO_DB\".\"UNIVERSITY_ART_GALLERY\".\"EXHIBITION\" AS T2 ON T1.exhibition_id  =  T2.exhibition_id WHERE T2.year  =  2004",
    "startTime": "2023-03-21T13:39:45.040598-04:00",
    "endTime": "2023-03-21T13:05:07.040598-04:00",
    "duration": 163,
    "errorCode": null,
    "technologyContext": {
      "type": "SnowflakeContext",
      "host": "example.snowflakecomputing.com",
      "snowflakeUsername": "taylor@snowflake.com",
      "rowsProduced": 3
    },
    "objectsAccessed": [
      {
        "columns": [
          {
            "name": "ATTENDANCE",
            "tags": [],
            "securityProfile": {
              "sensitivity": {
                "score": "NONSENSITIVE"
              }
            }
          },
          {
            "name": "DATE",
            "tags": [
              {
                "id": "97",
                "name": "Discovered.Entity.Date",
                "source": "curated"
              },
              {
                "id": "2522",
                "name": "Immuta DSF.Date",
                "source": "curated",
                "framework": {
                  "id": "4b4a2b1c-5862-4061-9c73-f562a56f127f",
                  "version": "543c62fe-5fbd-4829-9922-e271312af96d",
                  "name": "Immuta Data Security Framework",
                  "measures": {
                    "sensitivity": "NONSENSITIVE"
                  }
                }
              }
            ],
            "securityProfile": {
              "sensitivity": {
                "score": "NONSENSITIVE"
              }
            }
          },
          {
            "name": "EXHIBITION_ID",
            "tags": [],
            "securityProfile": {
              "sensitivity": {
                "score": "NONSENSITIVE"
              }
            }
          }
        ],
        "type": "TABLE",
        "name": "DETECT_DEMO_DB.UNIVERSITY_ART_GALLERY.EXHIBITION_RECORD",
        "tags": [],
        "securityProfile": {
          "sensitivity": {
            "score": "NONSENSITIVE"
          }
        }
      },
      {
        "columns": [
          {
            "name": "YEAR",
            "tags": [],
            "securityProfile": {
              "sensitivity": {
                "score": "NONSENSITIVE"
              }
            }
          },
          {
            "name": "EXHIBITION_ID",
            "tags": [],
            "securityProfile": {
              "sensitivity": {
                "score": "NONSENSITIVE"
              }
            }
          },
          {
            "name": "THEME",
            "tags": [],
            "securityProfile": {
              "sensitivity": {
                "score": "NONSENSITIVE"
              }
            }
          }
        ],
        "type": "TABLE",
        "name": "DETECT_DEMO_DB.UNIVERSITY_ART_GALLERY.EXHIBITION",
        "tags": [],
        "securityProfile": {
          "sensitivity": {
            "score": "NONSENSITIVE"
          }
        }
      }
    ],
    "securityProfile": {
      "sensitivity": {
        "score": "NONSENSITIVE"
      }
    }
  },
  "receivedTimestamp": "2023-03-22T13:22:04.979644-04:00"
}