[[["易于理解","easyToUnderstand","thumb-up"],["解决了我的问题","solvedMyProblem","thumb-up"],["其他","otherUp","thumb-up"]],[["很难理解","hardToUnderstand","thumb-down"],["信息或示例代码不正确","incorrectInformationOrSampleCode","thumb-down"],["没有我需要的信息/示例","missingTheInformationSamplesINeed","thumb-down"],["翻译问题","translationIssue","thumb-down"],["其他","otherDown","thumb-down"]],["最后更新时间 (UTC):2025-08-28。"],[],[],null,["# Metric naming conventions\n\nThis document describes the naming conventions Cloud Monitoring enforces\nfor metrics.\n\nMetric resource name\n--------------------\n\nThe *resource name* for a metric type consists of a\nstring with three primary sub-structures:\n\n- An identifier for a specific project.\n- A marker, which is always set to `metricDescriptors`, to indicate that the string represents a metric descriptor.\n- The metric type.\n\nResource names for metric types follow this pattern: \n\n```\nprojects/PROJECT_ID/metricDescriptors/METRIC_TYPE\n```\n\nThe sub-string \u003cvar translate=\"no\"\u003eMETRIC_TYPE\u003c/var\u003e is an identifier that represents the\nmetric type. It comes in a variety of formats, for example: \n\n```\nagent.googleapis.com/agent/api_request_count\ncompute.googleapis.com/firewall/dropped_bytes_count\nistio.io/service/client/received_bytes_count\nkubernetes.io/anthos/APIServiceOpenAPIAggregationControllerQueue1_adds\n```\n\nIn the metric descriptor, the `name` field stores the metric type's resource\nname, and the `type` field stores the \u003cvar translate=\"no\"\u003eMETRIC_TYPE\u003c/var\u003e sub-string.\n\nThe following table shows how to parse the \u003cvar translate=\"no\"\u003eMETRIC_TYPE\u003c/var\u003e sub-strings\ncontained in a resource name:\n\n^1^ \u003cvar translate=\"no\"\u003eSERVICE_NAME\u003c/var\u003e identifies a Google Cloud product, such as `compute` for Compute Engine. \n^2^ \u003cvar translate=\"no\"\u003ePATH\u003c/var\u003e identifies the metric within the product, such as `instance/cpu/utilization`.\n\nRules for metric types and labels\n---------------------------------\n\nThis list contains rules to follow when you create custom metric types. Labels\nassociated with a metric type are specified as key-value pairs of type\n[`LabelDescriptor`](/monitoring/api/ref_v3/rest/v3/LabelDescriptor). The key acts as the name of the label.\n\n- **Metric types**\n\n - Use upper and lower-case letters (`A-Z`, `a-z`), digits (`0-9`), periods (`.`), and underscores (`_`) in the string.\n - Use forward slashes (`/`) to separate path elements.\n - You must start each path element with a letter or digit.\n - The maximum length of a metric-type string is 200 characters.\n- **Label keys**\n\n - Use lower-case letters (`a-z`), digits (`0-9`), and underscores (`_`) in a label key.\n - You must start label keys with a letter.\n - The maximum length of a label key is 100 characters.\n - Each key must be unique within the metric type.\n - You can have no more than 30 labels per metric type."]]