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

Application Real-Time Monitoring Service:環境インスタンスのカスタムジョブの管理

最終更新日:Jun 18, 2026

Terraform を使用して、Prometheus スクレイプジョブを作成し、Container Service for Kubernetes (ACK) または Elastic Compute Service (ECS) 環境インスタンスにデプロイします。スクレイプターゲット、パス、間隔を設定することで、メトリクス収集を自動化できます。

前提条件

Container Service for Kubernetes (ACK) の環境があることを確認してください。詳細については、Terraform を使用して環境インスタンスを管理するをご参照ください。

制限事項

Container Service for Kubernetes (ACK) および Elastic Compute Service (ECS) 環境インスタンスにのみ対応しています。

環境インスタンスのカスタムジョブの追加

  1. 作業ディレクトリに main.tf という名前のファイルを作成し、カスタムジョブリソースを定義します。

    provider "alicloud" {
    # access_key = "************"
    # secret_key = "************"
    # region = "cn-beijing"
    }
    # 環境インスタンスのカスタムジョブを設定します。
    resource "alicloud_arms_env_custom_job" "my_custom_job1" {
    	env_custom_job_name = "my_custom_job1"
      environment_id = "env-xxxxx" # お使いの ACK または ECS 環境インスタンスの ID に置き換えてください。
      config_yaml    = <<-EOT
          scrape_configs:
          - job_name: job-demo1
            honor_timestamps: false
            honor_labels: false
            scrape_interval: 30s
            scheme: http
            metrics_path: /metric
            static_configs:
            - targets:
              - 127.0.0.1:9090
          - job_name: job-demo2
            honor_timestamps: false
            honor_labels: false
            scrape_interval: 30s
            scheme: http
            metrics_path: /metric
            static_configs:
            - targets:
              - 127.0.0.1:9090
            http_sd_configs:
            - url: 127.0.0.1:9090
              refresh_interval: 30s
    	EOT
    }
  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. 次のコマンドを実行して、実行計画を生成します。

    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_env_custom_job.my_custom_job1 will be created
     + resource "alicloud_arms_env_custom_job" "my_custom_job1" {
    				env_custom_job_name = "my_custom_job1"
    				environment_id = "xxx"
    				config_yaml = ....
     }
    
    Plan: 1 to add, 0 to change, 0 to destroy.
  4. 次のコマンドを実行して、カスタムジョブを作成します。

    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_env_custom_job.my_custom_job1 will be created
     + resource "alicloud_arms_env_custom_job" "my_custom_job1" {
    				env_custom_job_name = "my_custom_job1"
    				environment_id = "xxx"
    				config_yaml = ....
     }
    
    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

    Enter a value のプロンプトで、yes と入力して Enter キーを押し、カスタムジョブを作成します。

  5. にログインします。 ARMSコンソールを使用します。

  6. 左側のナビゲーションペインで、アクセス管理 をクリックします。アクセス管理 ページで、目的の環境インスタンスを見つけ、その名前をクリックします。

  7. 環境詳細ページで、メトリックの収集 タブをクリックし、カスタム収集 をクリックします。カスタムジョブが表示されていることを確認します。

カスタムジョブの削除

  1. 次のコマンドを実行して、カスタムジョブを削除します。

    terraform destroy

    想定される出力:

    ...
    Do you really want to destroy all resources?
     Terraform will destroy all your managed infrastructure, as shown above.
     There is no undo. Only 'yes' will be accepted to confirm.
    
     Enter a value: yes
    ...
    Destroy complete! Resources: 1 destroyed.

    Enter a value のプロンプトで、yes と入力して Enter キーを押します。

  2. にログインします。 ARMSコンソールを使用します。

  3. 左側のナビゲーションペインで、アクセス管理 をクリックします。アクセス管理 ページで、対象の環境インスタンスを見つけ、その名前をクリックします。

  4. 環境詳細ページで、メトリックの収集 タブをクリックし、次に カスタム収集 をクリックして、カスタムジョブが表示されなくなったことを確認します。