Method: projects.getMetrics
با مجموعهها، منظم بمانید
ذخیره و طبقهبندی محتوا براساس اولویتهای شما.
دادههای معیارهای اسکریپتها، مانند تعداد اجراها و کاربران فعال را دریافت کنید.
درخواست HTTP
GET https://script.googleapis.com/v1/projects/{scriptId}/metrics
URL از دستور GRPC Transcoding استفاده می کند.
پارامترهای مسیر
پارامترها |
---|
scriptId | string فیلد الزامی که نشاندهنده اسکریپت برای دریافت معیار است. |
پارامترهای پرس و جو
پارامترها |
---|
metricsGranularity | enum ( MetricsGranularity ) فیلد الزامی که نشان میدهد چه دانهای از معیارها برگردانده شدهاند. |
metricsFilter | object ( MetricsFilter ) فیلد اختیاری حاوی فیلترهایی برای اعمال به درخواست. این محدوده معیارهای بازگشتی را به موارد مشخص شده در فیلتر محدود می کند. |
درخواست بدن
بدنه درخواست باید خالی باشد.
بدن پاسخگو
در صورت موفقیت آمیز بودن، بدنه پاسخ حاوی داده هایی با ساختار زیر است:
منبعی حاوی آمار استفاده برای یک اسکریپت معین، بر اساس فیلتر و ماسک ارائه شده موجود در درخواست.
فیلدها |
---|
activeUsers[] | object ( MetricsValue ) تعداد کاربران فعال |
totalExecutions[] | object ( MetricsValue ) تعداد کل اعدام ها |
failedExecutions[] | object ( MetricsValue ) تعداد اعدام های ناموفق |
محدوده مجوز
به محدوده OAuth زیر نیاز دارد:
-
https://www.googleapis.com/auth/script.metrics
برای اطلاعات بیشتر، به نمای کلی OAuth 2.0 مراجعه کنید.
MetricsGranularity
دانه بندی متریک برای برگرداندن داده ها برای.
Enums |
---|
UNSPECIFIED_GRANULARITY | دانهبندی متریک پیشفرض برای پرسوجو بدون معیار استفاده میشود. |
WEEKLY | معیارهای هفتگی را نشان می دهد. |
DAILY | معیارهای روزانه را در یک دوره 7 روزه نشان می دهد. |
MetricsFilter
فیلتری که برای کاهش دامنه درخواست استفاده می شود.
نمایندگی JSON |
---|
{
"deploymentId": string
} |
فیلدها |
---|
deploymentId | string فیلد اختیاری که نشاندهنده استقرار خاصی برای بازیابی معیارها از آن است. |
MetricsValue
مقدار معیاری که تعداد اعدامها را شمارش میکند.
نمایندگی JSON |
---|
{
"value": string,
"startTime": string,
"endTime": string
} |
فیلدها |
---|
value | string تعداد اعدام های شمارش شده را نشان می دهد. |
startTime | string ( Timestamp format) فیلد الزامی که زمان شروع فاصله را نشان می دهد. مهر زمانی در قالب RFC3339 UTC "Zulu"، با وضوح نانوثانیه و حداکثر نه رقم کسری. مثالها: "2014-10-02T15:01:23Z" و "2014-10-02T15:01:23.045123456Z" . |
endTime | string ( Timestamp format) فیلد الزامی که زمان پایان بازه را نشان می دهد. مهر زمانی در قالب RFC3339 UTC "Zulu"، با وضوح نانوثانیه و حداکثر نه رقم کسری. مثالها: "2014-10-02T15:01:23Z" و "2014-10-02T15:01:23.045123456Z" . |
جز در مواردی که غیر از این ذکر شده باشد،محتوای این صفحه تحت مجوز Creative Commons Attribution 4.0 License است. نمونه کدها نیز دارای مجوز Apache 2.0 License است. برای اطلاع از جزئیات، به خطمشیهای سایت Google Developers مراجعه کنید. جاوا علامت تجاری ثبتشده Oracle و/یا شرکتهای وابسته به آن است.
تاریخ آخرین بهروزرسانی 2025-07-24 بهوقت ساعت هماهنگ جهانی.
[null,null,["تاریخ آخرین بهروزرسانی 2025-07-24 بهوقت ساعت هماهنگ جهانی."],[[["\u003cp\u003eRetrieve usage statistics for Apps Script projects, including active users, total executions, and failed executions.\u003c/p\u003e\n"],["\u003cp\u003eFilter metrics by granularity (daily, weekly) and specific deployments.\u003c/p\u003e\n"],["\u003cp\u003eRequires authorization with the \u003ccode\u003ehttps://www.googleapis.com/auth/script.metrics\u003c/code\u003e scope.\u003c/p\u003e\n"],["\u003cp\u003eThe API uses a \u003ccode\u003eGET\u003c/code\u003e request with path and query parameters to specify the script and desired metrics.\u003c/p\u003e\n"],["\u003cp\u003eResponse data includes metric values with start and end times for the specified intervals.\u003c/p\u003e\n"]]],[],null,["# Method: projects.getMetrics\n\n- [HTTP request](#body.HTTP_TEMPLATE)\n- [Path parameters](#body.PATH_PARAMETERS)\n- [Query parameters](#body.QUERY_PARAMETERS)\n- [Request body](#body.request_body)\n- [Response body](#body.response_body)\n - [JSON representation](#body.Metrics.SCHEMA_REPRESENTATION)\n- [Authorization Scopes](#body.aspect)\n- [MetricsGranularity](#MetricsGranularity)\n- [MetricsFilter](#MetricsFilter)\n - [JSON representation](#MetricsFilter.SCHEMA_REPRESENTATION)\n- [MetricsValue](#MetricsValue)\n - [JSON representation](#MetricsValue.SCHEMA_REPRESENTATION)\n- [Try it!](#try-it)\n\nGet metrics data for scripts, such as number of executions and active users.\n\n### HTTP request\n\n`GET https://script.googleapis.com/v1/projects/{scriptId}/metrics`\n\nThe URL uses [gRPC Transcoding](https://google.aip.dev/127) syntax.\n\n### Path parameters\n\n| Parameters ||\n|------------|-------------------------------------------------------------------|\n| `scriptId` | `string` Required field indicating the script to get metrics for. |\n\n### Query parameters\n\n| Parameters ||\n|----------------------|-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|\n| `metricsGranularity` | `enum (`[MetricsGranularity](/apps-script/api/reference/rest/v1/projects/getMetrics#MetricsGranularity)`)` Required field indicating what granularity of metrics are returned. |\n| `metricsFilter` | `object (`[MetricsFilter](/apps-script/api/reference/rest/v1/projects/getMetrics#MetricsFilter)`)` Optional field containing filters to apply to the request. This limits the scope of the metrics returned to those specified in the filter. |\n\n### Request body\n\nThe request body must be empty.\n\n### Response body\n\nIf successful, the response body contains data with the following structure:\nResource containing usage stats for a given script, based on the supplied filter and mask present in the request.\n\n| JSON representation |\n|------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|\n| ``` { \"activeUsers\": [ { object (/apps-script/api/reference/rest/v1/projects/getMetrics#MetricsValue) } ], \"totalExecutions\": [ { object (/apps-script/api/reference/rest/v1/projects/getMetrics#MetricsValue) } ], \"failedExecutions\": [ { object (/apps-script/api/reference/rest/v1/projects/getMetrics#MetricsValue) } ] } ``` |\n\n| Fields ||\n|----------------------|-------------------------------------------------------------------------------------------------------------------------------|\n| `activeUsers[]` | `object (`[MetricsValue](/apps-script/api/reference/rest/v1/projects/getMetrics#MetricsValue)`)` Number of active users. |\n| `totalExecutions[]` | `object (`[MetricsValue](/apps-script/api/reference/rest/v1/projects/getMetrics#MetricsValue)`)` Number of total executions. |\n| `failedExecutions[]` | `object (`[MetricsValue](/apps-script/api/reference/rest/v1/projects/getMetrics#MetricsValue)`)` Number of failed executions. |\n\n### Authorization Scopes\n\nRequires the following OAuth scope:\n\n- `https://www.googleapis.com/auth/script.metrics`\n\nFor more information, see the [OAuth 2.0 Overview](https://developers.google.com/identity/protocols/OAuth2).\n\nMetricsGranularity\n------------------\n\nThe granularity of metric to return data for.\n\n| Enums ||\n|---------------------------|------------------------------------------------------|\n| `UNSPECIFIED_GRANULARITY` | Default metric granularity used to query no metrics. |\n| `WEEKLY` | Represents weekly metrics. |\n| `DAILY` | Represents daily metrics over a period of 7 days. |\n\nMetricsFilter\n-------------\n\nFilter used to reduce the scope of the request.\n\n| JSON representation |\n|------------------------------------|\n| ``` { \"deploymentId\": string } ``` |\n\n| Fields ||\n|----------------|------------------------------------------------------------------------------------|\n| `deploymentId` | `string` Optional field indicating a specific deployment to retrieve metrics from. |\n\nMetricsValue\n------------\n\nMetrics value that holds number of executions counted.\n\n| JSON representation |\n|---------------------------------------------------------------------|\n| ``` { \"value\": string, \"startTime\": string, \"endTime\": string } ``` |\n\n| Fields ||\n|-------------|--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|\n| `value` | `string` Indicates the number of executions counted. |\n| `startTime` | `string (`[Timestamp](https://developers.google.com/protocol-buffers/docs/reference/google.protobuf#google.protobuf.Timestamp)` format)` 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: `\"2014-10-02T15:01:23Z\"` and `\"2014-10-02T15:01:23.045123456Z\"`. |\n| `endTime` | `string (`[Timestamp](https://developers.google.com/protocol-buffers/docs/reference/google.protobuf#google.protobuf.Timestamp)` format)` 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: `\"2014-10-02T15:01:23Z\"` and `\"2014-10-02T15:01:23.045123456Z\"`. |"]]