Monitoring を使用するには、適切な Identity and Access Management(IAM)権限が必要です。一般に、API の各 REST メソッドには権限が関連付けられています。このメソッドを使用するか、このメソッドに依存するコンソール機能を使用するには、対応するメソッドを使用する権限が必要です。権限はユーザーに直接付与されるのではなく、ロールを通して間接的に付与されます。ロールは、複数の権限をグループ化して管理しやすいようにしたものです。
- アクセス制御の詳細については、アクセス管理に関連するコンセプトをご覧ください。
- プリンシパルにロールを付与する方法については、Cloud Monitoring へのアクセス権を付与するをご覧ください。
一般的な権限の組み合わせを含むロールは事前に定義されています。ただし、IAM カスタムロールを作成して、独自の権限の組み合わせを作成することもできます。
Cloud Monitoring へのアクセス権を付与する
プリンシパルの IAM ロールを管理するには、 Google Cloud コンソールの [Identity and Access Management] ページまたは Google Cloud CLI を使用します。ただし、Cloud Monitoring には Monitoring 固有のロール、プロジェクト レベルのロール、Cloud Logging と Cloud Trace の一般的なロールを管理できるシンプルなインターフェースが用意されています。
プリンシパルに Monitoring、Cloud Logging、Cloud Trace へのアクセス権を付与するか、プロジェクト レベルのロールを付与するには、次のようにします。
コンソール
-
Google Cloud コンソールで、[
権限] ページに移動します。検索バーを使用してこのページを検索する場合は、小見出しが [Monitoring] である結果を選択します。
[アクセス権を持つプリンシパル] ページには、すべてのプリンシパルが表示されるわけではありません。プロジェクト レベルのロールを持つプリンシパル、または Monitoring、Logging、Trace に固有のロールのみが一覧表示されます。
このページのオプションを使用すると、ロールに Monitoring の権限が含まれるすべてのプリンシパルを表示できます。
[
アクセスを許可] をクリックします。[新しいプリンシパル] をクリックし、プリンシパルのユーザー名を入力します。複数のプリンシパルを追加できます。
[arrow_drop_down ロールを選択] を開き、[プロダクトまたはサービス] メニューから値を選択してから、[ロール] メニューからロールを選択します。
プロダクトまたはサービスの選択 ロールの選択 説明 Monitoring モニタリング閲覧者 Monitoring データと構成情報の表示。たとえば、このロールを持つプリンシパルは、カスタム ダッシュボードとアラート ポリシーを表示できます。 Monitoring モニタリング編集者 Monitoring データの表示、構成の作成と編集。たとえば、このロールを持つプリンシパルは、カスタム ダッシュボードとアラート ポリシーを作成できます。 Monitoring モニタリング管理者 Google Cloud コンソールの Monitoring と Cloud Monitoring API への完全アクセス権。Monitoring データの表示、構成の作成と編集、指標スコープの変更を行うことができます。 Cloud Trace Cloud Trace ユーザー Trace コンソールへの完全アクセス権、トレースへの読み取りアクセス権、シンクへの読み取り / 書き込みアクセス権。詳細については、Trace のロールをご覧ください。 Cloud Trace Cloud Trace 管理者 Trace コンソールへの完全アクセス権、トレースへの読み取り / 書き込みアクセス権、シンクへの読み取り / 書き込みアクセス権。詳細については、Trace のロールをご覧ください。 Logging ログ閲覧者 ログの閲覧権限。詳細については、Logging のロールをご覧ください。 Logging ロギング管理者 Cloud Logging のすべての機能に対する完全アクセス。詳細については、Logging のロールをご覧ください。 プロジェクト 閲覧者 ほとんどの Google Cloud リソースに対する閲覧権限。 プロジェクト 編集者 ほとんどの Google Cloud リソースの表示、作成、更新、削除。 プロジェクト オーナー ほとんどの Google Cloud リソースに対する完全アクセス。 省略可: 同じプリンシパルに別のロールを付与するには、[別のロールを追加] をクリックして前の手順を繰り返します。
[保存] をクリックします。
上記の手順では、 Google Cloud コンソールの [Monitoring] ページを使用して、プリンシパルに特定のロールを付与する方法について説明しています。これらのロールについて、このページでは編集や削除を行うこともできます。
プリンシパルのロールを削除するには、プリンシパルの横にあるチェックボックスをオンにして、[
アクセス権を削除] をクリックします。プリンシパルのロールを編集するには、[edit 編集] をクリックします。設定を更新したら、[保存] をクリックします。
gcloud
gcloud projects add-iam-policy-binding
コマンドを使用して monitoring.viewer
または monitoring.editor
ロールを付与します。
例:
export PROJECT_ID="my-test-project"
export EMAIL_ADDRESS="[email protected]"
gcloud projects add-iam-policy-binding \
$PROJECT_ID \
--member="user:$EMAIL_ADDRESS" \
--role="roles/monitoring.editor"
付与されたロールは、gcloud projects get-iam-policy
コマンドを使用して確認できます。
export PROJECT_ID="my-test-project"
gcloud projects get-iam-policy $PROJECT_ID
事前定義ロール
このセクションでは、Cloud Monitoring で事前定義されている IAM ロールのサブセットについて説明します。
名称 役割 |
含まれている権限 |
---|---|
roles/monitoring.viewer モニタリング閲覧者 |
Cloud Monitoring API への読み取り専用アクセス権を付与します。 |
roles/monitoring.editor モニタリング編集者 |
Cloud Monitoring API への読み取り / 書き込みアクセス権を付与します。 |
roles/monitoring.admin モニタリング管理者 |
Cloud Monitoring API への完全アクセス権を付与します。 |
サービス アカウントでは、書き込み専用アクセスとして以下のロールを使用します。
名称 役割 |
説明 |
---|---|
roles/monitoring.metricWriter モニタリング指標の書き込み |
このロールは、サービス アカウントとエージェント用です。 |
事前定義ロールの権限
このセクションでは、Monitoring に関連付けられている事前定義ロールに割り当てられている権限について説明します。
事前定義ロールの詳細については、IAM: ロールと権限をご覧ください。最適な事前定義ロールを選択する方法については、事前定義ロールの選択をご覧ください。
Monitoring のロールの権限
Role | Permissions |
---|---|
Monitoring Admin( Provides full access to Cloud Monitoring. Lowest-level resources where you can grant this role:
|
|
Monitoring AlertPolicy Editor( Read/write access to alerting policies. |
|
Monitoring AlertPolicy Viewer( Read-only access to alerting policies. |
|
Monitoring Alert Viewer Beta( Read access to alerts. |
|
Monitoring Cloud Console Incident Editor Beta( Read/write access to incidents from Cloud Console. |
|
Monitoring Cloud Console Incident Viewer Beta( Read access to incidents from Cloud Console. |
|
Monitoring Dashboard Configuration Editor( Read/write access to dashboard configurations. |
|
Monitoring Dashboard Configuration Viewer( Read-only access to dashboard configurations. |
|
Monitoring Editor( Provides full access to information about all monitoring data and configurations. Lowest-level resources where you can grant this role:
|
|
Monitoring Metric Writer( Provides write-only access to metrics. This provides exactly the permissions needed by the Cloud Monitoring agent and other systems that send metrics. Lowest-level resources where you can grant this role:
|
|
Monitoring Metrics Scopes Admin Beta( Access to add and remove monitored projects from metrics scopes. |
|
Monitoring Metrics Scopes Viewer Beta( Read-only access to metrics scopes and their monitored projects. |
|
Monitoring NotificationChannel Editor Beta( Read/write access to notification channels. |
|
Monitoring NotificationChannel Viewer Beta( Read-only access to notification channels. |
|
Monitoring Service Agent( Grants permissions to deliver notifications directly to resources within the target project, such as delivering to Pub/Sub topics within the project. |
|
Monitoring Services Editor( Read/write access to services. |
|
Monitoring Services Viewer( Read-only access to services. |
|
Monitoring Snooze Editor(
|
|
Monitoring Snooze Viewer(
|
|
Monitoring Uptime Check Configuration Editor Beta( Read/write access to uptime check configurations. |
|
Monitoring Uptime Check Configuration Viewer Beta( Read-only access to uptime check configurations. |
|
Monitoring Viewer( Provides read-only access to get and list information about all monitoring data and configurations. Lowest-level resources where you can grant this role:
|
|
Ops Config Monitoring Resource Metadata Viewer Beta( Read-only access to resource metadata. |
|
Ops Config Monitoring Resource Metadata Writer Beta( Write-only access to resource metadata. This provides exactly the permissions needed by the Ops Config Monitoring metadata agent and other systems that send metadata. |
|
Stackdriver Accounts Editor( Read/write access to manage Stackdriver account structure. |
|
Stackdriver Accounts Viewer( Read-only access to get and list information about Stackdriver account structure. |
|
Stackdriver Resource Metadata Writer Beta( Write-only access to resource metadata. This provides exactly the permissions needed by the Stackdriver metadata agent and other systems that send metadata. |
|
Google Cloud 基本ロールに含まれている Monitoring の権限
Google Cloud 基本ロールには次の権限が含まれています。
名称 役割 |
含まれている権限 |
---|---|
roles/viewer 閲覧者 |
モニタリング権限は、roles/monitoring.viewer の権限と同じです。
|
roles/editor 編集者 |
Monitoring の権限は、 |
roles/owner オーナー |
Monitoring の権限は、roles/monitoring.admin の権限と同じです。
|
Compute Engine のアクセス スコープ
アクセス スコープは、Compute Engine VM インスタンスに関する権限を指定するレガシーな方法です。Monitoring には次のアクセス スコープが適用されます。
アクセス スコープ | 付与される権限 |
---|---|
https://www.googleapis.com/auth/monitoring.read | roles/monitoring.viewer に含まれる権限と同じ。 |
https://www.googleapis.com/auth/monitoring.write | roles/monitoring.metricWriter に含まれる権限と同じ。 |
https://www.googleapis.com/auth/monitoring | Monitoring に対する完全アクセス権。 |
https://www.googleapis.com/auth/cloud-platform | 有効にされているすべての Cloud API に対する完全アクセス権。 |
詳しくは、アクセス スコープをご覧ください。
ベスト プラクティス。VM インスタンスに最も強力なアクセス スコープ(cloud-platform
)を付与したうえで、IAM ロールを使用して特定の API やオペレーションへのアクセスを制限することをおすすめします。詳しくは、サービス アカウント権限をご覧ください。