Enabling Logging and Event Sharing for an Application¶
This topic describes how to enable logging and event sharing to troubleshoot an application. Logging and trace events allow you to get performance and diagnostic information if an application encounters any errors. These are shared with the application provider.
Workflow for Enabling Logging and Event Sharing as a Consumer¶
As a consumer, you can enable logging and event sharing for an application by performing the following:
Considerations for Enabling Logging and Event Sharing¶
Before enabling logging and event sharing for an application, you must consider the following:
This feature requires you to set up an event table in your account.
After you enable event sharing, a masked and redacted copy of the logs and trace events is automatically captured in the event table of a designated provider account.
Snowflake does not charge you for enabling event sharing. However, you are responsible for the cost of log and event ingestion and storage in the event table.
After sharing events with a provider, you cannot revoke access to shared logs and trace events.
You cannot share historical events using event sharing.
You cannot share a subset of events or apply a filter.
Snowflake sends the shared events to a designated provider account within the same region as your account. This feature does not share data across different regions.
You cannot change the logging or tracing levels for an application because the provider sets the levels.
Snowflake recommends reviewing the logs and events in the event table before enabling event sharing.
Snowflake recommends disabling logging and event sharing if you do not need to troubleshoot the application.
Setting Up an Event Table¶
The Native Apps Framework requires an event table to store log messages and trace events generated from functions and stored procedures in an application.
Note
If you do not set up an event table and make it the active table before installing the application, logging and event data is discarded.
An account can have multiple event tables, but only one of them can be set as the active event table for a Snowflake account at a time. Without an active event table, log messages and trace events generated by the application are not captured. This is true even if the functions and procedures in an application call the logging and trace event APIs.
Use the CREATE EVENT TABLE command to create an event table as shown in the following example:
CREATE EVENT TABLE event_db.event_schema.my_event_table;
After creating the event table, use the ALTER ACCOUNT command 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;
Viewing the Events in the Event Table¶
Both the provider and consumer can query the event table to see the events being stored. Use the SELECT command to query the logs and trace events from the event table, for example:
SELECT * FROM event_db.event_schema.my_event_table;
Viewing the Logging and Trace Event Levels for an Application¶
As a consumer, you cannot change the log level of an application. However, before enabling logging for an application, Snowflake recommends verifying the log level to understand the type of information to be shared with the provider.
To view the logging level of an installed application, run the following command:
DESC APPLICATION HelloSnowflake;
This command displays information about the HelloSnowflake
application, including the values for
log_level
and trace_level
.
Enabling Logging and Event Sharing for an Application¶
To share logs and event information with a provider, you must enable event sharing for an application.
The following prerequisites must be met to enable event sharing for an application instance:
Use a role with the MANAGE EVENT SHARING global privilege. The ACCOUNTADMIN role has this privilege by default and can grant it to other roles.
To enable event sharing for an application, run the
ALTER APPLICATION command to set
SHARE_EVENTS_WITH_PROVIDER to TRUE
. For example:
ALTER APPLICATION HellowSnowflake SET SHARE_EVENTS_WITH_PROVIDER = TRUE;
To show the event sharing status for an application, use the DESC APPLICATION command as shown in the following example:
DESC APPLICATION HelloSnowflake;
SHARE_EVENTS_WITH_PROVIDER
shows the status of event sharing for the application.