Categories:

Table functions (Snowpark Container Services)

<service_name>!SPCS_GET_METRICS

Returns the metrics that Snowflake collected for the specified service. For more information, see Access platform metrics.

See also:

Monitoring Services

Syntax

<service_name>!SPCS_GET_METRICS(
    [ START_TIME => <constant_expr> ],
    [ END_TIME => <constant_expr> ] )

Arguments

START_TIME => constant_expr

Start time (in TIMESTAMP_LTZ format) for the time range from which to retrieve metrics. For available functions to construct data, time, and timestamp data, see Date & time functions.

If the START_TIME isn’t specified, it defaults to one day ago.

END_TIME => constant_expr

End time (in TIMESTAMP_LTZ format) for the time range from which to retrieve metrics.

If END_TIME isn’t specified, it defaults to the current timestamp.

Output

The function returns the following columns:

ColumnData TypeDescription
TIMESTAMPTIMESTAMP_NTZUniversal Coordinated Time (UTC) timestamp when Snowflake collected the metric.
METRIC_NAMEVARCHARName of the metric.
VALUEVARCHARValue of the metric.
UNITVARCHARUnit of the metric returned.
INSTANCE_IDNUMBERName of the service instance if the metric is related to the service instance.
CONTAINER_NAMEVARCHARName of the container if the metric is related to the container. For example, a volume metric won’t have container name.
RESOURCEVARCHARHardware — for example, GPU — the metrics is about. This column isn’t populated.
RECORDOBJECTKey-value pairs that provide metric information.
RECORD_ATTRIBUTESOBJECTKey-value pairs that provide additional information about the metric.

Access control requirements

A role used to execute this operation must have the following privileges at a minimum:

PrivilegeObjectNotes
MONITORService

Operating on an object in a schema requires at least one privilege on the parent database and at least one privilege on the parent schema.

For instructions on creating a custom role with a specified set of privileges, see Creating custom roles.

For general information about roles and privilege grants for performing SQL actions on securable objects, see Overview of Access Control.

Usage notes

  • It can take a few minutes before metrics appear in the output.

Examples

Retrieve the metrics that Snowflake collected for the my_test_job job over the past day, the default.

SELECT * FROM TABLE(mydb.myschema.my_test_job!SPCS_GET_METRICS());

Retrieve the metrics that Snowflake collected for the my_test_job job over the past three days.

SELECT * from TABLE(mydb.myschema.my_test_job!SPCS_GET_METRICS(start_time => DATEADD('day', -3, CURRENT_TIMESTAMP())));

Retrieve metrics from the past day for the spcs_get_metrics job instance 0 in the container named main.

SELECT * FROM TABLE(mydb.myschema.my_test_job!SPCS_GET_METRICS())
 WHERE instance_id = 0 AND container_name = 'main';