Pub/Sub의 라벨은 비용 관리 및 리소스 구성에 도움이 됩니다. 예를 들어 다양한 유형의 뉴스 업데이트에 대해 여러 구독이 있다고 가정해 보겠습니다. news_category=sports 또는 news_category=entertainment과 같은 관련 카테고리로 각 구독에 라벨을 지정할 수 있습니다.
라벨이란 무엇인가요?
라벨은 Google Cloud 리소스에 할당할 수 있는 키-값 쌍입니다.
이러한 리소스를 구성하고 필요한 세부사항으로 규모에 맞게 비용을 관리하는 데 도움이 됩니다. 각 리소스에 라벨을 연결한 후 이 라벨을 기준으로 리소스를 필터링할 수 있습니다. 라벨에 대한 정보는 청구 요금을 라벨별로 분류할 수 있는 결제 시스템으로 전달됩니다. 기본 제공되는 결제 보고서를 통해 리소스 라벨별로 비용을 필터링하고 그룹화할 수 있습니다. 라벨을 사용하여 결제 데이터 내보내기를 쿼리할 수도 있습니다.
라벨 요구사항
리소스에 적용된 라벨은 다음 요구사항을 충족해야 합니다.
각 리소스에 라벨을 최대 64개까지 사용할 수 있습니다.
각 라벨은 키-값 쌍이어야 합니다.
키는 비워 둘 수 없으며 최소 길이는 1자(영문 기준)이고 최대 길이는 63자(영문 기준)입니다. 값은 비워 둘 수 있으며 최대 길이는 63자(영문 기준)입니다.
키와 값에는 소문자, 숫자, 밑줄, 대시만 사용할 수 있습니다. 모든 문자는 UTF-8 인코딩을 사용해야 하며 국제 문자가 허용됩니다. 키는 소문자나 국제 문자로 시작해야 합니다.
라벨의 키 부분은 단일 리소스에서 고유해야 합니다.
그러나 여러 리소스에 같은 키를 사용할 수 있습니다.
이러한 한도는 각 라벨의 키와 값 및 라벨이 있는 개별 Google Cloud 리소스에 적용됩니다. 한 프로젝트의 모든 리소스에 적용할 수 있는 라벨 수에는 제한이 없습니다.
라벨의 일반적인 사용 사례
다음은 라벨의 몇 가지 일반적인 사용 사례입니다.
팀 또는 비용 센터 라벨: 팀 또는 비용 센터를 기준으로 라벨을 추가하여 서로 다른 팀(예: team:research 및 team:analytics)에서 소유하는 리소스를 구분할 수 있습니다. 비용 계산이나 예산 책정에 이 유형의 라벨을 사용할 수 있습니다.
구성요소 라벨: component:redis, component:frontend, component:ingest, component:dashboard를 예시로 들 수 있습니다.
환경 또는 단계 라벨: environment:production과 environment:test를 예로 들 수 있습니다.
상태 라벨: state:active , state:readytodelete, state:archive를 예로 들 수 있습니다.
소유권 라벨: 작업을 담당하는 팀을 식별하는 데 사용됩니다(예: team:shopping-cart).
모든 API 호출의 타임스탬프 또는 개별 값과 같은 다수의 고유 라벨을 만들지 않는 것이 좋습니다.
이 접근 방식의 문제는 값이 자주 변경되거나 카탈로그를 복잡하게 하는 키로 인해 리소스를 효과적으로 필터링하고 보고하기 어렵다는 것입니다.
라벨 및 태그
라벨은 리소스에 대해 쿼리 가능한 주석으로 사용될 수 있지만 정책에 조건을 설정하는 데는 사용할 수 없습니다. 태그를 사용하면 정책을 세밀하게 제어하여 리소스에 특정 태그가 있는지 여부에 따라 정책을 조건부로 허용하거나 거부할 수 있습니다. 자세한 내용은 태그 개요를 참조하세요.
Pub/Sub 라벨 관리
Pub/Sub에서 라벨은 특정 결제 계정의 수수료를 구성하는 데 종종 사용됩니다. 수수료는 요청된 리소스를 포함하는 프로젝트의 결제 계정과 연결되지만 추가 연결을 설정할 수도 있습니다. 예를 들어 다른 프로젝트에 속하는 주제에 대해 하나의 프로젝트에 속한 구독을 만들 수 있습니다. 라벨을 사용하면 해당 주제와 구독을 공통 비용 센터와 연결할 수 있습니다.
Pub/Sub 리소스 간에 라벨은 상속되지 않습니다. 이전 예시에서는 주제와 구독에 동일한 라벨을 설정하여 해당 청구를 연결할 수 있습니다.
[[["이해하기 쉬움","easyToUnderstand","thumb-up"],["문제가 해결됨","solvedMyProblem","thumb-up"],["기타","otherUp","thumb-up"]],[["이해하기 어려움","hardToUnderstand","thumb-down"],["잘못된 정보 또는 샘플 코드","incorrectInformationOrSampleCode","thumb-down"],["필요한 정보/샘플이 없음","missingTheInformationSamplesINeed","thumb-down"],["번역 문제","translationIssue","thumb-down"],["기타","otherDown","thumb-down"]],["최종 업데이트: 2025-09-04(UTC)"],[],[],null,["# Reporting usage with labels\n\nLabels in Pub/Sub help you with cost management and resource\norganization. For example, imagine you have multiple subscriptions for different\ntypes of news updates. You can label each subscription with a relevant category,\nsuch as `news_category=sports` or `news_category=entertainment`.\n\nWhat are labels?\n----------------\n\nA label is a key-value pair that you can assign to Google Cloud resources.\nThey help you organize these resources and manage your costs at scale, with the\ngranularity you need. You can attach a label to each resource, then filter the\nresources based on their labels. Information about labels is forwarded to the billing system that\nlets you break down your billed charges by label. With built-in [billing reports](/billing/docs/how-to/reports),\nyou can filter and group costs by resource labels. You can also use labels to\nquery [billing data exports](/billing/docs/how-to/bq-examples).\n\nRequirements for labels\n-----------------------\n\nThe labels applied to a resource must meet the following\nrequirements:\n\n- Each resource can have up to 64 labels.\n- Each label must be a key-value pair.\n- Keys have a minimum length of 1 character and a maximum length of 63 characters, and cannot be empty. Values can be empty, and have a maximum length of 63 characters.\n- Keys and values can contain only lowercase letters, numeric characters, underscores, and dashes. All characters must use UTF-8 encoding, and international characters are allowed. Keys must start with a lowercase letter or international character.\n- The key portion of a label must be unique within a single resource. However, you can use the same key with multiple resources.\n\nThese limits apply to the key and value for each label, and to the\nindividual Google Cloud resources that have labels. There\nis no limit on how many labels you can apply across all resources\nwithin a project.\n\nCommon uses of labels\n---------------------\n\nHere are some common use cases for labels:\n\n- **Team or cost center labels** : Add labels based on team or\n cost center to distinguish resources owned by different\n teams (for example, `team:research` and `team:analytics`). You can use this\n type of label for cost accounting or budgeting.\n\n- **Component labels** : For example, `component:redis`,\n `component:frontend`, `component:ingest`, and `component:dashboard`.\n\n- **Environment or stage labels** : For example,\n `environment:production` and `environment:test`.\n\n- **State labels** : For example, `state:active`,\n `state:readytodelete`, and `state:archive`.\n\n- **Ownership labels** : Used to identify the teams that are\n responsible for operations, for example: `team:shopping-cart`.\n\n\n| **Note:** Don't include sensitive information in labels, including personally identifiable information, such as an individual's name or title. Labels are not designed to handle sensitive information.\n\nWe don't recommend creating large numbers of unique labels, such as\nfor timestamps or individual values for every API call.\nThe problem with this approach is that when the values change frequently or with\nkeys that clutter the catalog, this makes it difficult to effectively filter and\nreport on resources.\n\nLabels and tags\n---------------\n\nLabels can be used as queryable annotations for resources, but can't be used\nto set conditions on policies. Tags provide a way to conditionally allow or\ndeny policies based on whether a resource has a specific tag, by providing fine-grained\ncontrol over policies. For more information, see the\n[Tags overview](/resource-manager/docs/tags/tags-overview).\n\nManaging labels in Pub/Sub\n--------------------------\n\nIn Pub/Sub, labels are often used to organize\n[fees](/pubsub/pricing) for a given billing account. Fees are associated with\nthe billing account of the project that contains the requested resource, but you\nmight want to establish additional associations. For example, a subscription\nthat belongs to one project might be created for a topic that belongs to a\ndifferent project. You can use labels to associate that topic\nand subscription with a common cost center.\n| **Note:** While you can use labels to organize fees by billing account, no additional fees are charged for the use of Pub/Sub labels.\n\nPub/Sub resources don't inherit labels from each other. In the\npreceding example, you would set the same label on both the topic and the\nsubscription in order to associate those charges.\n\nYou can use the following features to apply labels to Pub/Sub\nresources:\n\n- The [Google Cloud console](https://console.cloud.google.com/cloudpubsub): Select a resource and change to the **LABELS** tab.\n- [Pub/Sub Client Libraries](/pubsub/docs/reference/libraries) (specifically [Java](/java/docs/reference/google-cloud-pubsub/latest/overview) and [Python](/python/docs/reference/pubsub/latest)).\n- The [Google Cloud CLI for Pub/Sub](/sdk/gcloud/reference/pubsub). For example, see the [create topic](/sdk/gcloud/reference/pubsub/topics/create) command."]]