获取监控 API

编辑

根据 ID 检索监控。

请求

编辑

GET _watcher/watch/<watch_id>

先决条件

编辑
  • 您必须拥有 manage_watchermonitor_watcher 集群权限才能使用此 API。有关更多信息,请参阅 安全权限

路径参数

编辑
<watch_id>
(必需,字符串) 监控的标识符。

示例

编辑

以下示例获取 ID 为 my_watch 的监控

resp = client.watcher.get_watch(
    id="my_watch",
)
print(resp)
const response = await client.watcher.getWatch({
  id: "my_watch",
});
console.log(response);
GET _watcher/watch/my_watch

响应

{
  "found": true,
  "_id": "my_watch",
  "_seq_no": 0,
  "_primary_term": 1,
  "_version": 1,
  "status": { 
    "version": 1,
    "state": {
      "active": true,
      "timestamp": "2015-05-26T18:21:08.630Z"
    },
    "actions": {
      "test_index": {
        "ack": {
          "timestamp": "2015-05-26T18:21:08.630Z",
          "state": "awaits_successful_execution"
        }
      }
    }
  },
  "watch": {
    "input": {
      "simple": {
        "payload": {
          "send": "yes"
        }
      }
    },
    "condition": {
      "always": {}
    },
    "trigger": {
      "schedule": {
        "hourly": {
          "minute": [0, 5]
        }
      }
    },
    "actions": {
      "test_index": {
        "index": {
          "index": "test"
        }
      }
    }
  }
}

监控的当前状态