全部產品
Search
文件中心

Elasticsearch:ListEcsInstances

更新時間:Jan 16, 2025

建立Beats採集器時,調用ListEcsInstances,擷取ECS機器列表。

重要 介面前置需要建立AliyunElasticsearchAccessingOOSRole和AliyunOOSAccessingECS4ESRole的系統服務角色,用於Elasticsearch服務帳號擷取主帳號的ECS存取權限等,詳細資料請參見採集ECS服務日誌

調試

您可以在OpenAPI Explorer中直接運行該介面,免去您計算簽名的困擾。運行成功後,OpenAPI Explorer可以自動產生SDK程式碼範例。

要求標頭

該介面使用公用要求標頭,無特殊要求標頭。請參見公用請求參數文檔。

請求文法

GET /openapi/ecs HTTP/1.1

請求參數

名稱 類型 位置 是否必選 樣本值 描述
page Integer Query 1

返回結果頁數。最大值500。

size Integer Query 10

每頁包含的結果數。預設值10,最大值500。

ecsInstanceIds String Query ["i-bp13y63575oypr9d****","i-bp1gyhphjaj73jsr****"]

ECS執行個體ID列表。取值可以由多個執行個體ID組成一個JSON數組,最多支援100個ID,ID之間用半形逗號(,)隔開。

ecsInstanceName String Query test

ECS執行個體名稱。

tags String Query [{ "tagKey":"a","tagValue":"b"}]

ECS執行個體標籤,必須包含:

  • tagKey:標籤鍵
  • tagValue:標籤值
vpcId String Query vpc-bp16k1dvzxtmagcva****

ECS執行個體所在的VPC ID。

返回資料

名稱 類型 樣本值 描述
RequestId String 5FFD9ED4-C2EC-4E89-B22B-1ACB6FE1D***

請求ID。

Headers Object

返回頭資訊。

X-Total-Count Integer 11

返回的記錄數。

Result Array of Result

返回結果。

cloudAssistantStatus String true

雲助手安裝狀態,支援:

  • true:已安裝
  • false:未安裝
ecsInstanceName String ecsTestName

ECS執行個體名稱。

ecsInstanceId String i-bp14ncqge8wy3l3d****

ECS執行個體ID。

tags String [ { "tagKey": "a", "tagValue": "b" } ]

ECS執行個體的標籤資訊。

osType String linux

ECS執行個體的作業系統類型。支援:

  • windows:Windows作業系統
  • linux:Linux作業系統
status String running

ECS執行個體的狀態。支援:

  • running:運行中
  • starting:啟動中
  • stopping:停止中
  • stopped:已停止
ipAddress Array of ipAddress

ECS執行個體的IP地址資訊。

ipType String private

IP地址類型。支援:

  • public:公網地址
  • private:私網地址
host String 172.16.xx.xx

IP地址。

collectors Array of collectors

該ECS執行個體上,採集器資訊列表。

resId String ct-cn-0v3xj86085dvq****

採集器執行個體ID。

gmtUpdateTime String 2020-06-20T07:26:47.000+0000

採集器更新時間。

dryRun Boolean false

是否校正並建立採集器。支援:

  • true:只校正不建立
  • false:校正並建立
ownerId String 16852***488*****

帳號ID。

vpcId String vpc-bp16k1dvzxtm******

採集器所在的專用網路ID。

resType String fileBeat

採集器類型。支援fileBeat、metricBeat、heartBeat和auditBeat。

resVersion String 6.8.5_with_community

採集器版本。採集器部署的機器類型為ECS時,只支援6.8.5_with_community

gmtCreatedTime String 2020-06-20T07:26:47.000+0000

採集器建立時間。

status String activing

採集器狀態。支援:

  • activing:生效中
  • active:已生效
name String ct-testAbc

採集器名稱。

configs Array of configs

採集器的設定檔資訊。

content String - key: log\n title: Log file content\n description: >\n Contains log file lines.\n ....

檔案內容。

fileName String fields.yml

檔案名稱。

extendConfigs Array of extendConfigs

擴充參數資訊。

enableMonitoring Boolean true

是否啟用Monitoring,當configTypecollectorTargetInstance,且instanceTypeelasticsearch時顯示。支援:

  • true:啟用
  • false:不啟用
groupId String default_ct-cn-5i2l75bz4776****

機器組ID。當configTypecollectorDeployMachine時顯示。

configType String collectorDeployMachine

配置類型。支援:

  • collectorTargetInstance:採集器Output
  • collectorDeployMachine:採集器的部署機器
  • collectorElasticsearchForKibana:支援Kibana儀錶盤的Elasticsearch執行個體資訊
instanceType String elasticsearch

採集器Output指定的執行個體類型。支援elasticsearch、logstash。當configTypecollectorTargetInstance時顯示。

protocol String HTTP

傳輸協議,需要與採集器Output指定執行個體的訪問協議保持一致。支援HTTP、HTTPS。當configTypecollectorTargetInstance時顯示。

userName String elastic

採集器Output指定執行個體的訪問使用者名稱,預設為elastic。當configTypecollectorTargetInstancecollectorElasticsearchForKibana時顯示。

type String ECSInstanceId

採集器部署的機器類型,當configTypecollectorDeployMachine時顯示。支援:

  • ECSInstanceId:ECS
  • ACKCluster:容器Kubernetes
instanceId String es-cn-nif1z89fz003i****

採集器關聯的執行個體ID。當configTypecollectorTargetInstance時,為採集器Output的執行個體ID;當configTypecollectorDeployMachines,且typeACKCluster時,為ACK(容器Kubernetes)叢集ID。

machines Array of machines

採集器所部署的ECS機器列表資訊。當configTypecollectorDeployMachines,且typeECSInstanceId時顯示。

agentStatus String heartOk

ECS上各採集器的狀態。支援:

  • heartOk:心跳正常
  • heartLost:心跳異常
  • uninstalled:未安裝
  • failed:安裝失敗
instanceId String i-bp13y63575oypr9d****

ECS機器ID列表。

hosts Array of String ["es-cn-n6w1o1x*****.elasticsearch.aliyuncs.com:9200"]

採集器Output指定執行個體的訪問地址清單。當configTypecollectorTargetInstance時顯示。

collectorPaths Array of String ["/var/log"]

Filebeat的採集路徑。

樣本

請求樣本

GET /openapi/ecs?page=1&size=10 HTTP/1.1
Host:elasticsearch.aliyuncs.com
Content-Type:application/json

正常返回樣本

JSON格式

HTTP/1.1 200 OK
Content-Type:application/json

{
  "Result" : [ {
    "ecsInstanceId" : "i-bp1gyhphjaj73jsr****",
    "ecsInstanceName" : "test",
    "status" : "running",
    "ipAddress" : [ {
      "host" : "47.98.xx.xx",
      "ipType" : "public"
    }, {
      "host" : "172.16.xx.xx",
      "ipType" : "private"
    } ],
    "tags" : [ ],
    "collectors" : [ {
      "gmtCreatedTime" : "2020-12-30T08:04:32.000+0000",
      "gmtUpdateTime" : "2020-12-30T08:20:48.000+0000",
      "name" : "uptime-test",
      "resId" : "ct-cn-4135is2tj194p****",
      "resVersion" : "6.8.5_with_community",
      "vpcId" : "vpc-bp16k1dvzxtmagcva****",
      "resType" : "heartBeat",
      "ownerId" : "168520994880****",
      "configs" : [ {
        "fileName" : "fields.yml"
      }, {
        "fileName" : "heartbeat.yml"
      } ],
      "status" : "active",
      "extendConfigs" : [ {
        "configType" : "collectorTargetInstance",
        "instanceId" : "es-cn-n6w1o1x0w001c****",
        "instanceType" : "elasticsearch",
        "hosts" : [ "es-cn-n6w1o1x0w001c****.elasticsearch.aliyuncs.com:9200" ],
        "protocol" : "HTTP",
        "userName" : "elastic",
        "enableMonitoring" : true
      }, {
        "configType" : "collectorDeployMachine",
        "type" : "ECSInstanceId",
        "machines" : [ {
          "instanceId" : "i-bp1gyhphjaj73jsr****",
          "agentStatus" : "heartOk"
        } ],
        "groupId" : "default_ct-cn-4135is2tj194p****"
      } ],
      "dryRun" : false
    } ],
    "osType" : "linux",
    "cloudAssistantStatus" : "true"
  } ],
  "RequestId" : "58E5DE98-33B0-4D9B-B5F6-E70A77C5933E",
  "Headers" : {
    "X-Total-Count" : 2
  }
}

錯誤碼

訪問錯誤中心查看更多錯誤碼。