すべてのプロダクト
Search
ドキュメントセンター

Application Real-Time Monitoring Service:Terraform を使用して Prometheus インスタンスのモニタリング設定を管理する

最終更新日:Jan 09, 2025

このトピックでは、Terraform を使用して、ServiceMonitor、PodMonitor、カスタムジョブ、ヘルス検査エージェントなどの Prometheus インスタンスのモニタリング設定を管理する方法について説明します。

前提条件

  • コンテナサービスまたは ECS の Prometheus インスタンスが作成されていること。 詳細については、「Terraform を使用して Prometheus インスタンスを管理する」をご参照ください。

  • Terraform がインストールされていること。

    • デフォルトでは、Cloud Shell には Terraform がプリインストールされており、アカウント情報が構成されています。構成を変更する必要はありません。

    • Cloud Shell を使用しない場合は、Terraform を直接インストールできます。 詳細については、「Terraform のインストールと構成」をご参照ください。

      説明
      • terraform --version コマンドを実行して、Terraform のバージョンを確認する必要があります。 Terraform V0.12.28 以降をインストールする必要があります。

      • Resource Orchestration Service ( ROS ) は、Alibaba Cloud が提供するネイティブの Infrastructure as Code ( IaC ) サービスですが、Terraform テンプレートの統合もサポートしています。 ROS で Terraform を使用することにより、Alibaba Cloud、Amazon Web Services ( AWS )、または Microsoft Azure のリソースを定義および管理し、リソースパラメータを指定し、リソースの依存関係を構成できます。 詳細については、「Terraform テンプレートの作成」および「Terraform スタックの作成」をご参照ください。

  • Alibaba Cloud アカウント情報が構成されていること。次のいずれかの方法を使用して、Alibaba Cloud アカウント情報を構成できます。

    説明

    権限管理の柔軟性とセキュリティを向上させるために、Terraform という名前の Resource Access Management ( RAM ) ユーザーを作成することをお勧めします。次に、RAM ユーザーの AccessKey ペアを作成し、RAM ユーザーに権限を付与します。 詳細については、「RAM ユーザーの作成」および「RAM ユーザーへの権限の付与」をご参照ください。

    • 方法 1:認証情報を格納する環境変数を追加します。

      export ALICLOUD_ACCESS_KEY="************" // AccessKey ID
      export ALICLOUD_SECRET_KEY="************" // AccessKey Secret
      export ALICLOUD_REGION="cn-beijing"       // リージョン
      
      説明

      ビジネス要件に基づいて export ALICLOUD_REGION パラメータの値を指定します。

    • 方法 2:構成ファイルの provider セクションで ID 情報を指定します。

      provider "alicloud" {
        access_key = "************"  // AccessKey ID
        secret_key = "************"  // AccessKey Secret
        region     = "cn-beijing"    // リージョン
      }
      
      説明

      ビジネス要件に基づいて export ALICLOUD_REGION パラメータの値を指定します。

制限事項

  • コンテナサービスの Prometheus インスタンス:ServiceMonitor、PodMonitor、カスタムジョブ、ヘルス検査エージェントがサポートされています。

  • ECS の Prometheus インスタンス:カスタムジョブとヘルス検査エージェントのみがサポートされています。

  • ヘルス検査エージェント:

    • Status パラメータはサポートされていません。

    • Custom name-{tcp/http/ping}-blackbox の形式でヘルス検査エージェントの名前を作成します。たとえば、xxx-tcp-blackbox という名前のエージェントは TCP 検査を示します。

    • ECS の Prometheus インスタンスはフルマネージドです。したがって、エージェントの名前空間は空であるか、固定されている必要があります。名前空間の例:vpcId-userId。エージェント名の例:vpc-0jl4q1q2of2tagvwxxxx-11032353609xxxx

Prometheus インスタンスにモニタリング設定を追加する

ServiceMonitor を追加する

  1. 作業ディレクトリと、そのディレクトリに main.tf という名前のファイルを作成します。

    provider "alicloud" {
    } // プロバイダーの構成
    
  2. 次のコマンドを実行して、Terraform のランタイム環境を初期化します。

    terraform init
    

    期待される出力:

    Initializing the backend... // バックエンドの初期化
    
    Initializing provider plugins... // プロバイダープラグインの初期化
    - Checking for available provider plugins... // 利用可能なプロバイダープラグインの確認
    - Downloading plugin for provider "alicloud" (hashicorp/alicloud) 1.90.1... // プロバイダー "alicloud" のプラグインのダウンロード
    ...
    
    You may now begin working with Terraform. Try running "terraform plan" to see // Terraform の使用を開始できます。"terraform plan" を実行して変更を確認してください。
    any changes that are required for your infrastructure. All Terraform commands // インフラストラクチャに必要な変更点を確認してください。すべての Terraform コマンドが機能するはずです。
    should now work.
    
    If you ever set or change modules or backend configuration for Terraform, // Terraform のモジュールまたはバックエンド構成を設定または変更した場合は、このコマンドを再実行して作業ディレクトリを再初期化してください。
    rerun this command to reinitialize your working directory. If you forget, other // 忘れた場合は、他のコマンドがそれを検出し、必要に応じて再実行するように指示します。
    commands will detect it and remind you to do so if necessary.
    
  3. モニタリングリソースをインポートします。

    1. main.tf ファイルにモニタリングリソースを追加します。

      # Prometheus インスタンスの ServiceMonitor 構成。
      resource "alicloud_arms_prometheus_monitoring" "myServiceMonitor1" {
        cluster_id       = "c77e1106f429e4b46b0ee1720cxxxxx"   // Prometheus インスタンスの ID。
        status      = "run"   // ServiceMonitor のステータス。
        type        = "serviceMonitor" // ServiceMonitor のタイプ
        config_yaml = <<-EOT
      					apiVersion: monitoring.coreos.com/v1 // API バージョン
      					kind: ServiceMonitor               // リソースの種類
      					metadata:
      					  name: tomcat-demo    // ServiceMonitor の名前。
      					  namespace: default   // ServiceMonitor が存在する名前空間。
      					spec:
      					  endpoints:
      					    - interval: 30s    // メトリックを取得する間隔。単位:秒。
      					      path: /metrics   // 取得したメトリックを保存するパス。
      					      port: tomcat-monitor   // メトリックを取得するポートの名前。
      					  namespaceSelector:
      					    any: true           // オプション。サービスが存在する名前空間。
      					  selector:
      					    matchLabels:
      					      app: tomcat       // オプション。サービスに添付されているタグ。
      			EOT // 構成の終わり
      }
      

    2. 次のコマンドを実行して、実行プランを作成します。

      terraform plan
      

      期待される出力:

      Terraform used the selected providers to generate the following execution plan. Resource actions are indicated with the following symbols: // Terraform は選択されたプロバイダーを使用して、次の実行プランを生成しました。リソースアクションは次の記号で示されます。
        + create // 作成
      
      Terraform will perform the following actions: // Terraform は次のアクションを実行します。
      
        # alicloud_arms_prometheus_monitoring.myServiceMonitor1 will be created // alicloud_arms_prometheus_monitoring.myServiceMonitor1 が作成されます
        + resource "alicloud_arms_prometheus_monitoring" "myServiceMonitor1" { // リソース "alicloud_arms_prometheus_monitoring" "myServiceMonitor1"
            + cluster_id        = "c77e1106f429e4b46b0ee1720cxxxxx" // クラスタ ID
            + id                = (known after apply)                // ID(適用後に分かります)
            + monitoring_name = (known after apply) // モニタリング名(適用後に分かります)
        		+ status      = "run"                               // ステータス
       			+ type        = "serviceMonitor"                   // タイプ
      			+ config_yaml = <<-EOT                             // 構成
      						apiVersion: monitoring.coreos.com/v1
      						kind: ServiceMonitor
      						metadata:
      						  name: tomcat-demo
      						  namespace: default
      						spec:
      						  endpoints:
      						    - interval: 30s
      						      path: /metrics
      						      port: tomcat-monitor
      						  namespaceSelector:
      						    any: true
      						  selector:
      						    matchLabels:
      						      app: tomcat
              EOT
          }
      
      Plan: 1 to add, 0 to change, 0 to destroy. // プラン:1 を追加、0 を変更、0 を破棄。
      

    3. 次のコマンドを実行して、ServiceMonitor を作成します。

      terraform apply
      

      期待される出力:

      Terraform used the selected providers to generate the following execution plan. Resource actions are indicated with the following symbols:
        + create
      
      Terraform will perform the following actions:
      
        # alicloud_arms_prometheus_monitoring.myServiceMonitor1 will be created
        + resource "alicloud_arms_prometheus_monitoring" "myServiceMonitor1" {
            + cluster_id        = "c77e1106f429e4b46b0ee1720c9xxxxx"
            + id                = (known after apply)
            + monitoring_name = (known after apply)
        		+ status      = "run"   
       			+ type        = "serviceMonitor"
      			+ config_yaml = <<-EOT
      						apiVersion: monitoring.coreos.com/v1
      						kind: ServiceMonitor
      						metadata:
      						  name: tomcat-demo
      						  namespace: default
      						spec:
      						  endpoints:
      						    - interval: 30s
      						      path: /metrics
      						      port: tomcat-monitor
      						  namespaceSelector:
      						    any: true
      						  selector:
      						    matchLabels:
      						      app: tomcat
              EOT
          }
      
      Plan: 1 to add, 0 to change, 0 to destroy.
      
      Do you want to perform these actions? // これらのアクションを実行しますか?
        Terraform will perform the actions described above. // Terraform は上記のアクションを実行します。
        Only 'yes' will be accepted to approve.          // 承認するには「yes」のみが受け入れられます。
      
        Enter a value: yes                             // 値を入力してください:yes
      

      yes が返された場合、現在の Prometheus インスタンスに対して ServiceMonitor が作成されます。

結果の確認

Managed Service for Prometheus コンソールにログインし、Prometheus インスタンスの統合センターで ServiceMonitor の構成を表示できます。これを行うには、次の手順を実行します。

  1. ARMS コンソール にログインします。

  2. 左側のナビゲーションペインで、[managed Service For Prometheus] > [インスタンス] を選択します。

  3. 管理する Prometheus インスタンス インスタンスの名前をクリックして、統合センターページに移動します。

  4. [インストール済み] セクションのカスタムコンポーネントをクリックします。表示されたパネルで、[サービスディスカバリー構成] タブをクリックして、ServiceMonitor の構成を表示します。

PodMonitor を追加する

  1. 作業ディレクトリと、そのディレクトリに main.tf という名前のファイルを作成します。

    provider "alicloud" {
    } // プロバイダーの構成
    
  2. 次のコマンドを実行して、Terraform のランタイム環境を初期化します。

    terraform init
    

    期待される出力:

    Initializing the backend...
    
    Initializing provider plugins...
    - Checking for available provider plugins...
    - Downloading plugin for provider "alicloud" (hashicorp/alicloud) 1.90.1...
    ...
    
    You may now begin working with Terraform. Try running "terraform plan" to see
    any changes that are required for your infrastructure. All Terraform commands
    should now work.
    
    If you ever set or change modules or backend configuration for Terraform,
    rerun this command to reinitialize your working directory. If you forget, other
    commands will detect it and remind you to do so if necessary.
    
  3. モニタリングリソースをインポートします。

    1. main.tf ファイルにモニタリングリソースを追加します。

      # Prometheus インスタンスの PodMonitor 構成。
      resource "alicloud_arms_prometheus_monitoring" "myPodMonitor1" {
        cluster_id       = "c77e1106f429e4b46b0ee1720cxxxxx"  // Prometheus インスタンスの ID。
        status      = "run"  // PodMonitor のステータス。
        type        = "podMonitor" // PodMonitor のタイプ
        config_yaml = <<-EOT
      			apiVersion: "monitoring.coreos.com/v1" // API バージョン
      			kind: "PodMonitor"                   // リソースの種類
      			metadata:
      			  name: "podmonitor-demo"  // PodMonitor の名前。
      			  namespace: "default"     // PodMonitor が存在する名前空間。
      			spec:
      			  namespaceSelector:
      			    any: true              // オプション。Pod が存在する名前空間。
      			  podMetricsEndpoints:
      			    - interval: "30s"      // メトリックを取得する間隔。単位:秒。
      			      path: "/metrics"     // 取得したメトリックを保存するパス。
      			      port: "tomcat-monitor"  // メトリックを取得するポートの名前。
      			  selector:
      			    matchLabels:
      			      app: "nginx2-exporter"   // オプション。Pod に添付されているタグ。
      			EOT // 構成の終わり
      }
      

    2. 次のコマンドを実行して、実行プランを作成します。

      terraform plan
      

      期待される出力:

      Terraform used the selected providers to generate the following execution plan. Resource actions are indicated with the following symbols:
        + create
      
      Terraform will perform the following actions:
      
        # alicloud_arms_prometheus_monitoring.myPodMonitor1 will be created
        + resource "alicloud_arms_prometheus_monitoring" "myPodMonitor1" {
            + cluster_id        = "c77e1106f429e4b46b0ee1720cxxxxx"
            + id                = (known after apply)
            + monitoring_name = (known after apply)
        		+ status      = "run"   
       			+ type        = "podMonitor"
      			+ config_yaml = <<-EOT
      						apiVersion: "monitoring.coreos.com/v1"
      						kind: "PodMonitor"
      						metadata:
      						  name: "podmonitor-demo"
      						  namespace: "default"
      						spec:
      						  namespaceSelector:
      						    any: true
      						  podMetricsEndpoints:
      						    - interval: "30s"
      						      path: "/metrics"
      						      port: "tomcat-monitor"
      						  selector:
      						    matchLabels:
      						      app: "nginx2-exporter"
              EOT
          }
      
      Plan: 1 to add, 0 to change, 0 to destroy.
      

    3. 次のコマンドを実行して、PodMonitor を作成します。

      terraform apply
      

      期待される出力:

      Terraform used the selected providers to generate the following execution plan. Resource actions are indicated with the following symbols:
        + create
      
      Terraform will perform the following actions:
      
        # alicloud_arms_prometheus_monitoring.myPodMonitor1 will be created
        + resource "alicloud_arms_prometheus_monitoring" "myPodMonitor1" {
            + cluster_id        = "c77e1106f429e4b46b0ee1720c9xxxxx"
            + id                = (known after apply)
            + monitoring_name = (known after apply)
        		+ status      = "run"   
       			+ type        = "podMonitor"
      			+ config_yaml = <<-EOT
      						apiVersion: "monitoring.coreos.com/v1"
      						kind: "PodMonitor"
      						metadata:
      						  name: "podmonitor-demo"
      						  namespace: "default"
      						spec:
      						  namespaceSelector:
      						    any: true
      						  podMetricsEndpoints:
      						    - interval: "30s"
      						      path: "/metrics"
      						      port: "tomcat-monitor"
      						  selector:
      						    matchLabels:
      						      app: "nginx2-exporter"
              EOT
          }
      
      Plan: 1 to add, 0 to change, 0 to destroy.
      
      Do you want to perform these actions?
        Terraform will perform the actions described above.
        Only 'yes' will be accepted to approve.
      
        Enter a value: yes
      

      yes が返された場合、現在の Prometheus インスタンスに対して PodMonitor が作成されます。

結果の確認

Managed Service for Prometheus コンソールにログインし、Prometheus インスタンスの統合センターで PodMonitor の構成を表示できます。これを行うには、次の手順を実行します。

  1. ARMS コンソール にログインします。

  2. 左側のナビゲーションペインで、[managed Service For Prometheus] > [インスタンス] を選択します。

  3. 管理する Prometheus インスタンス インスタンスの名前をクリックして、統合センターページに移動します。

  4. [インストール済み] セクションのカスタムコンポーネントをクリックします。表示されたパネルで、[サービスディスカバリー構成] タブをクリックして、PodMonitor の構成を表示します。

カスタムジョブを追加する

  1. 作業ディレクトリと、そのディレクトリに main.tf という名前のファイルを作成します。

    provider "alicloud" {
    } // プロバイダーの構成
    
  2. 次のコマンドを実行して、Terraform のランタイム環境を初期化します。

    terraform init
    

    期待される出力:

    Initializing the backend...
    
    Initializing provider plugins...
    - Checking for available provider plugins...
    - Downloading plugin for provider "alicloud" (hashicorp/alicloud) 1.90.1...
    ...
    
    You may now begin working with Terraform. Try running "terraform plan" to see
    any changes that are required for your infrastructure. All Terraform commands
    should now work.
    
    If you ever set or change modules or backend configuration for Terraform,
    rerun this command to reinitialize your working directory. If you forget, other
    commands will detect it and remind you to do so if necessary.
    
  3. モニタリングリソースをインポートします。

    1. main.tf ファイルにモニタリングリソースを追加します。

      # Prometheus インスタンスのジョブ構成。
      resource "alicloud_arms_prometheus_monitoring" "myCustomJob1" {
        cluster_id       = "c77e1106f429e4b46b0ee1720cxxxxx"  // Prometheus インスタンスの ID。
        status      = "run"     // カスタムジョブのステータス。
        type        = "customJob" // カスタムジョブのタイプ
        config_yaml = <<-EOT
      			scrape_configs: // スクレイプ構成
      			  - job_name: prometheus1    // カスタムジョブの名前。
      			    honor_timestamps: false // タイムスタンプを尊重するかどうか
      			    honor_labels: false    // ラベルを尊重するかどうか
      			    scheme: http           // スキーム
      			    metrics_path: /metric  // メトリックパス
      			    static_configs:        // スタティック構成
      			      - targets:           // ターゲット
      			          - 127.0.0.1:9090 // ターゲットアドレス
      			EOT // 構成の終わり
      }
      

    2. 次のコマンドを実行して、実行プランを作成します。

      terraform plan
      

      期待される出力:

      Terraform used the selected providers to generate the following execution plan. Resource actions are indicated with the following symbols:
        + create
      
      Terraform will perform the following actions:
      
        # alicloud_arms_prometheus_monitoring.myCustomJob1 will be created
        + resource "alicloud_arms_prometheus_monitoring" "myCustomJob1" {
            + cluster_id        = "c77e1106f429e4b46b0ee1720cxxxxx"
            + id                = (known after apply)
            + monitoring_name = (known after apply)
        		+ status      = "run"   
       			+ type        = "customJob"
      			+ config_yaml = <<-EOT
      						scrape_configs:
      						  - job_name: prometheus1		 
      						    honor_timestamps: false
      						    honor_labels: false
      						    scheme: http
      						    metrics_path/metric
      						    static_configs:					
      						      - targets:
      						          - 127.0.0.1:9090
              EOT
          }
      
      Plan: 1 to add, 0 to change, 0 to destroy.
      

    3. 次のコマンドを実行して、カスタムジョブを作成します。

      terraform apply
      

      期待される出力:

      Terraform used the selected providers to generate the following execution plan. Resource actions are indicated with the following symbols:
        + create
      
      Terraform will perform the following actions:
      
        # alicloud_arms_prometheus_monitoring.myCustomJob1 will be created
        + resource "alicloud_arms_prometheus_monitoring" "myCustomJob1" {
            + cluster_id        = "c77e1106f429e4b46b0ee1720c9xxxxx"
            + id                = (known after apply)
            + monitoring_name = (known after apply)
        		+ status      = "run"   
       			+ type        = "customJob"
      			+ config_yaml = <<-EOT
      						scrape_configs:
      						  - job_name: prometheus1		 
      						    honor_timestamps: false
      						    honor_labels: false
      						    scheme: http
      						    metrics_path: /metric
      						    static_configs:					
      						      - targets:
      						          - 127.0.0.1:9090
              EOT
          }
      
      Plan: 1 to add, 0 to change, 0 to destroy.
      
      Do you want to perform these actions?
        Terraform will perform the actions described above.
        Only 'yes' will be accepted to approve.
      
        Enter a value: yes
      

      yes が返された場合、現在の Prometheus インスタンスに対してカスタムジョブが作成されます。

結果の確認

Managed Service for Prometheus コンソールにログインし、Prometheus インスタンスの統合センターでカスタムジョブの構成を表示できます。これを行うには、次の手順を実行します。

  1. ARMS コンソール にログインします。

  2. 左側のナビゲーションペインで、[managed Service For Prometheus] > [インスタンス] を選択します。

  3. 管理する Prometheus インスタンス インスタンスの名前をクリックして、統合センターページに移動します。

  4. [インストール済み] セクションのカスタムコンポーネントをクリックします。表示されたパネルで、[サービスディスカバリー構成] タブをクリックして、カスタムジョブの構成を表示します。

ヘルス検査エージェントを構成する

  1. 作業ディレクトリと、そのディレクトリに main.tf という名前のファイルを作成します。

    provider "alicloud" {
    } // プロバイダーの構成
    
  2. 次のコマンドを実行して、Terraform のランタイム環境を初期化します。

    terraform init
    

    期待される出力:

    Initializing the backend...
    
    Initializing provider plugins...
    - Checking for available provider plugins...
    - Downloading plugin for provider "alicloud" (hashicorp/alicloud) 1.90.1...
    ...
    
    You may now begin working with Terraform. Try running "terraform plan" to see
    any changes that are required for your infrastructure. All Terraform commands
    should now work.
    
    If you ever set or change modules or backend configuration for Terraform,
    rerun this command to reinitialize your working directory. If you forget, other
    commands will detect it and remind you to do so if necessary.
    
  3. モニタリングリソースをインポートします。

    1. main.tf ファイルにモニタリングリソースを追加します。

      # Prometheus インスタンスのエージェント構成。
      resource "alicloud_arms_prometheus_monitoring" "myProbe1" {
        cluster_id       = "c77e1106f429e4b46b0ee1720cxxxxx"  // Prometheus インスタンスの ID。
        type        = "probe" // プローブのタイプ
        config_yaml = <<-EOT
      			apiVersion: monitoring.coreos.com/v1 // API バージョン
      			kind: Probe                         // リソースの種類
      			metadata:
      				name: name1-tcp-blackbox  // エージェントの名前。形式:xxx-{tcp/http/ping}-blackbox。
      				namespace: arms-prom       // オプション。名前空間。
      			spec:
      				interval: 30s         // ヘルス検査を実行する間隔。
      				jobName: blackbox     // デフォルト値を維持します。
      				module: tcp_connect   // モジュール
      				prober:               // エージェントの構成情報。デフォルト値を維持します。
      					path: /blackbox/probe // パス
      					scheme: http         // スキーム
      					url: 'localhost:9335' // URL
      				targets:             // ターゲット
      					staticConfig:      // スタティック構成
      						static:         // スタティック
      							- 'arms-prom-admin.arms-prom:9335'  // ヘルス検査のアドレス。
      			EOT // 構成の終わり
      }
      

    2. 次のコマンドを実行して、実行プランを作成します。

      terraform plan
      

      期待される出力:

      Terraform used the selected providers to generate the following execution plan. Resource actions are indicated with the following symbols:
        + create
      
      Terraform will perform the following actions:
      
        # alicloud_arms_prometheus_monitoring.myProbe1 will be created
        + resource "alicloud_arms_prometheus_monitoring" "myProbe1" {
            + cluster_id        = "c77e1106f429e4b46b0ee1720cxxxxx"
            + id                = (known after apply)
            + monitoring_name = (known after apply)
        		+ type        = "probe"
      			+ config_yaml = <<-EOT
      						apiVersion: monitoring.coreos.com/v1
      						kind: Probe
      						metadata:
      						  name: name1-tcp-blackbox  
      						  namespace: arms-prom  
      						spec:
      						  interval: 30s
      						  jobName: blackbox
      						  module: tcp_connect
      						  prober:
      						    path: /blackbox/probe
      						    scheme: http
      						    url: 'localhost:9335'
      						  targets:
      						    staticConfig:
      						      static:
      						        - 'arms-prom-admin.arms-prom:9335'
              EOT
          }
      
      Plan: 1 to add, 0 to change, 0 to destroy.
      

    3. 次のコマンドを実行して、ヘルス検査エージェントを作成します。

      terraform apply
      

      期待される出力:

      Terraform used the selected providers to generate the following execution plan. Resource actions are indicated with the following symbols:
        + create
      
      Terraform will perform the following actions:
      
        # alicloud_arms_prometheus_monitoring.myProbe1 will be created
        + resource "alicloud_arms_prometheus_monitoring" "myProbe1" {
            + cluster_id        = "c77e1106f429e4b46b0ee1720c9xxxxx"
            + id                = (known after apply)
            + monitoring_name = (known after apply)
        		+ type        = "probe"
      			+ config_yaml = <<-EOT
      						apiVersion: monitoring.coreos.com/v1
      						kind: Probe
      						metadata:
      						  name: name1-tcp-blackbox  
      						  namespace: arms-prom  
      						spec:
      						  interval: 30s
      						  jobName: blackbox
      						  module: tcp_connect
      						  prober:
      						    path: /blackbox/probe
      						    scheme: http
      						    url: 'localhost:9335'
      						  targets:
      						    staticConfig:
      						      static:
      						        - 'arms-prom-admin.arms-prom:9335'
              EOT
          }
      
      Plan: 1 to add, 0 to change, 0 to destroy.
      
      Do you want to perform these actions?
        Terraform will perform the actions described above.
        Only 'yes' will be accepted to approve.
      
        Enter a value: yes
      

      yes が返された場合、現在の Prometheus インスタンスに対してヘルス検査エージェントが作成されます。

結果の確認

Managed Service for Prometheus コンソールにログインし、Prometheus インスタンスの統合センターでエージェントの構成を表示できます。これを行うには、次の手順を実行します。

  1. ARMS コンソール にログインします。

  2. 左側のナビゲーションペインで、[managed Service For Prometheus] > [インスタンス] を選択します。

  3. 管理する Prometheus インスタンス インスタンスの名前をクリックして、統合センターページに移動します。

  4. ブラックボックス[インストール済み] セクションの ヘルスチェック コンポーネントをクリックします。表示されたパネルで、 タブをクリックして、エージェントの構成を表示します。

Prometheus インスタンスからモニタリング設定を削除する

手順

次のコマンドを実行して、Terraform を使用して作成されたクラスタを削除できます。

terraform destroy

期待される出力

...
Do you really want to destroy all resources? // すべてのリソースを本当に破棄しますか?
  Terraform will destroy all your managed infrastructure, as shown above. // Terraform は、上記のように、管理対象のすべてのインフラストラクチャを破棄します。
  There is no undo. Only 'yes' will be accepted to confirm. // 元に戻すことはできません。確認するには「yes」のみが受け入れられます。

  Enter a value: yes // 値を入力してください:yes
...
Destroy complete! Resources: 1 destroyed. // 破棄完了!リソース:1 個破棄されました。

結果の確認

Managed Service for Prometheus コンソールにログインし、Prometheus インスタンスの統合センターでモニタリング設定が削除されているかどうかを確認できます。

  1. ARMS コンソール にログインします。

  2. 左側のナビゲーションペインで、[managed Service For Prometheus] > [インスタンス] を選択します。

  3. 管理する Prometheus インスタンス インスタンスの名前をクリックして、統合センターページに移動します。

  4. カスタムブラックボックス[インストール済み] セクションの [カスタム] または [Blackbox] コンポーネントをクリックします。表示されたパネルで、 または タブをクリックして、モニタリング設定が削除されているかどうかを確認します。