AI-generated Key Takeaways
- 
          This page describes how to get metrics data for scripts, such as number of executions and active users. 
- 
          Metrics data is retrieved using a GET request to the provided URL, specifying the script ID in the path parameters. 
- 
          Query parameters allow for specifying the granularity of metrics and applying filters. 
- 
          The response body contains usage stats, including the number of active users, total executions, and failed executions, represented as a JSON object. 
- 
          Authorization requires the https://www.googleapis.com/auth/script.metricsOAuth scope.
- HTTP request
- Path parameters
- Query parameters
- Request body
- Response body
- Authorization Scopes
- MetricsGranularity
- MetricsFilter
- MetricsValue
- Try it!
Get metrics data for scripts, such as number of executions and active users.
HTTP request
GET https://script.googleapis.com/v1/projects/{scriptId}/metrics
The URL uses gRPC Transcoding syntax.
Path parameters
| Parameters | |
|---|---|
| scriptId | 
 Required field indicating the script to get metrics for. | 
Query parameters
| Parameters | |
|---|---|
| metricsGranularity | 
 Required field indicating what granularity of metrics are returned. | 
| metricsFilter | 
 Optional field containing filters to apply to the request. This limits the scope of the metrics returned to those specified in the filter. | 
Request body
The request body must be empty.
Response body
If successful, the response body contains data with the following structure:
Resource containing usage stats for a given script, based on the supplied filter and mask present in the request.
| JSON representation | 
|---|
| { "activeUsers": [ { object ( | 
| Fields | |
|---|---|
| activeUsers[] | 
 Number of active users. | 
| totalExecutions[] | 
 Number of total executions. | 
| failedExecutions[] | 
 Number of failed executions. | 
Authorization Scopes
Requires the following OAuth scope:
- https://www.googleapis.com/auth/script.metrics
For more information, see the OAuth 2.0 Overview.
MetricsGranularity
The granularity of metric to return data for.
| Enums | |
|---|---|
| UNSPECIFIED_GRANULARITY | Default metric granularity used to query no metrics. | 
| WEEKLY | Represents weekly metrics. | 
| DAILY | Represents daily metrics over a period of 7 days. | 
MetricsFilter
Filter used to reduce the scope of the request.
| JSON representation | 
|---|
| { "deploymentId": string } | 
| Fields | |
|---|---|
| deploymentId | 
 Optional field indicating a specific deployment to retrieve metrics from. | 
MetricsValue
Metrics value that holds number of executions counted.
| JSON representation | 
|---|
| { "value": string, "startTime": string, "endTime": string } | 
| Fields | |
|---|---|
| value | 
 Indicates the number of executions counted. | 
| startTime | 
 Required field indicating the start time of the interval. A timestamp in RFC3339 UTC "Zulu" format, with nanosecond resolution and up to nine fractional digits. Examples:  | 
| endTime | 
 Required field indicating the end time of the interval. A timestamp in RFC3339 UTC "Zulu" format, with nanosecond resolution and up to nine fractional digits. Examples:  |