Enable 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:

  1. Review the considerations for enabling logging and event sharing.

  2. Set up an event table.

  3. View the logging level specified by the provider.

  4. View the events in the event table.

  5. Enable logging and event sharing on an application.

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.

Set 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;
Copy

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;
Copy

View 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;
Copy

View 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;
Copy

This command displays information about the HelloSnowflake application, including the values for log_level and trace_level.

Enable 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:

Enable logging and event sharing using Snowsight

Providers can include a Streamlit app to display a dialog Snowsight that allows consumers to enable logging and event sharing in their account. To use Snowsight to enable logging and event sharing has the following requirements:

  • An event table is already configured. See Set up an event table for more information.

  • You must use a role that has been granted the MANAGE EVENT SHARING privilege.

To enable event sharing for an application:

  1. Sign in to Snowsight.

  2. In the navigation menu, select Data Products » Apps.

  3. Select the application.

  4. Select the Security icon in the toolbar.

  5. Select the Telemetry tab.

  6. Use the slider to enable event sharing for the app.

  7. If no event table is currently selected, select the event table from the list.

    Caution

    Use caution when changing the event table in Snowsight. Each Snowflake account uses a single event table for all events generated within the account. Changing the event table causes all events generated in the account to be stored in the new location.

Enable logging and event sharing using SQL

To enable event sharing for an application, run the ALTER APPLICATION command to set SHARE_EVENTS_WITH_PROVIDER to TRUE. For example:

ALTER APPLICATION HelloSnowflake SET SHARE_EVENTS_WITH_PROVIDER = TRUE;
Copy

To show the event sharing status for an application, use the DESC APPLICATION command as shown in the following example:

DESC APPLICATION HelloSnowflake;
Copy

SHARE_EVENTS_WITH_PROVIDER shows the status of event sharing for the application.