日本熟妇hd丰满老熟妇,中文字幕一区二区三区在线不卡 ,亚洲成片在线观看,免费女同在线一区二区

使用Terraform管理環境實例的ServiceMonitor

通過在Terraform中配置ServiceMonitor資源并添加至Prometheus,幫助您發現并收集特定服務的性能指標,實現運維團隊對系統性能的精準監控,從而提升系統的性能和健康。

前提條件

已創建容器服務類型的環境。具體操作,請參見使用Terraform管理環境實例。

使用限制

僅支持容器服務類型的環境。

為容器服務環境實例添加ServiceMonitor

  1. 創建一個工作目錄,并在工作目錄中創建名為main.tf的配置文件,用于配置ServiceMonitor資源。

    provider "alicloud" {
    # access_key = "************"
    # secret_key = "************"
    # region = "cn-beijing"
    }
    # 容器服務環境實例的ServiceMonitor配置。
    resource "alicloud_arms_env_service_monitor" "my-service-monitor1" {
      environment_id = "容器服務環境的ID,如env-xxxxx"
      config_yaml    = <<-EOT
          apiVersion: monitoring.coreos.com/v1
          kind: ServiceMonitor
          metadata:
            name: my-service-monitor1 #serviceMonitor名稱
            namespace: arms-prom  #serviceMonitor的命名空間
            annotations:
              arms.prometheus.io/discovery: 'true' #arms-prometheus固定要求的annotation,true則表示當前serviceMonitor有效,false則表示無效。
          spec:
            endpoints:
            - interval: 30s
              port: operator
              path: /metrics
            - interval: 10s
              port: operator1
              path: /metrics
            namespaceSelector:
              any: true
            selector:
              matchLabels:
               app: xxx
    	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_service_monitor.myServiceMonitor1 will be created
     + resource "alicloud_arms_env_service_monitor" "myServiceMonitor1" {
    				environment_id = "xxx"
    				config_yaml = ....
     }
    
    Plan: 1 to add, 0 to change, 0 to destroy.
  4. 執行以下命令,創建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_env_service_monitor.myServiceMonitor1 will be created
     + resource "alicloud_arms_env_service_monitor" "myServiceMonitor1" {
    				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,當前環境實例的ServiceMonitor配置創建成功。

  5. 登錄ARMS控制臺

  6. 在左側導航欄,單擊接入管理。在接入管理頁面的環境列表中,單擊目標環境名稱進入詳情頁面。

  7. 在環境詳情頁面,單擊指標采集頁簽,在ServiceMonitor列表中查看是否已成功創建ServiceMonitor配置。

刪除容器服務環境實例的ServiceMonitor

  1. 執行以下命令,刪除通過Terraform創建的集群。

    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。

  2. 登錄ARMS控制臺。

  3. 在左側導航欄,單擊接入管理。在接入管理頁面的環境列表中,單擊目標環境名稱進入詳情頁面。

  4. 在環境詳情頁面,單擊指標采集頁簽,在ServiceMonitor列表中查看是否已成功刪除ServiceMonitor配置。