Set up and manage an event table in the provider account¶
This topic describes how providers can set up an event table and manage event sharing for an app.
Set up an event table in the provider organization in every region¶
To collect the log messages and trace events that a consumer shares, a provider must set up an event table by performing the following:
Important
If a provider does not have an event account and active event table withing the region where the app is installed before the consumer installs an app, trace events and log messages are discarded.
Set an account as the events account¶
To store shared logs and events, a provider must select an account to hold an event table. This can be any account that a provider can access. However, if an organization has multiple providers publishing application packages, consider using a Snowflake account that is dedicated to storing shared events from the consumer.
The following restrictions apply to accounts used to store shared events:
You must use the ORGADMIN role to set an account as the account used to store events.
The account must have an active event table.
The specified account cannot be any of the following:
A locked or suspended account.
A reader account.
A trial account.
A Snowflake managed account.
Note
A provider can collect logs and shared events only in the same region where a consumer installs an app. Providers must set up an event account to store shared events in every region where consumers configure event sharing for an app.
To set an account to be the events account for a region, call the SYSTEM$SET_EVENT_SHARING_ACCOUNT_FOR_REGION system function as shown in the following example:
SELECT SYSTEM$SET_EVENT_SHARING_ACCOUNT_FOR_REGION('<snowflake_region>', '<region_group>', '<account_name>')
Where:
snowflake_region
Specifies the region where the account is located, for example:
AWS_US_WEST_2, AWS_US_EAST_1
.region_group
Specifies the region group, for example:
PUBLIC
. Refer to Region groups for details.account_name
Specifies the account name. If another account is already set as the events account in the specified region, running this command changes the events account to be the account specified here.
Create an event table in the event account¶
To create an event table, run the CREATE EVENT TABLE command as shown in the following example:
CREATE EVENT TABLE event_db.event_schema.my_event_table;
This command specifies the database and schema that contain the event table.
Set the event table as the active event table¶
An account can have multiple event tables, but only one can be set as the active event table in a Snowflake account at a time. Without an active event table, log messages and trace events that the consumer shares are discarded.
After creating the event table, use ALTER ACCOUNT … SET EVENT_TABLE to specify that the event table is the active table for the account:
ALTER ACCOUNT SET EVENT_TABLE=event_db.event_schema.my_event_table;
Unset an account as the events account¶
To unset an account to be the events account for a region, call the SYSTEM$UNSET_EVENT_SHARING_ACCOUNT_FOR_REGION system function:
SELECT SYSTEM$UNSET_EVENT_SHARING_ACCOUNT_FOR_REGION('<snowflake_region>', '<region_group>', '<account_name>')
Where:
snowflake_region
Specifies the region where the account is located, for example:
AWS_US_WEST_2
.region_group
Specifies the region group, for example:
PUBLIC
.account_name
Specifies the account name.
View the event accounts in an organization¶
To show events accounts in a provider’s organization, call the SYSTEM$SHOW_EVENT_SHARING_ACCOUNTS system function:
SELECT SYSTEM$SHOW_EVENT_SHARING_ACCOUNTS()
Note
You must use the ORGADMIN role to call this function.
This system function returns a string in JSON format containing a list of event accounts within the organization. Because the metadata takes some time to propagate to all regions, this function might have a short delay before showing the most current events account after the user sets or unsets the event account for the organization.
View the logging and trace event levels defined in an application package¶
Use the SHOW VERSIONS command to view the logging level of the app versions defined in an application package, as shown in the following example:
SHOW VERSIONS
IN APPLICATION PACKAGE HelloSnowflake;
View the logs and events in the event table¶
To view the logs and events stored in the event table, use the SELECT command as shown in the following example:
SELECT * FROM EVENT_DB.EVENT_SCHEMA.MY_EVENT_TABLE
For more information on querying the event table, see the following:
See Event table columns for information on the columns in the event table.