当前位置: 首页 > 知识库问答 >
问题:

如何检查Elasticsearch群集运行状况?

庾奇思
2023-03-14

我试图通过

curl -XGET 'http://localhost:9200/_cluster/health'

但是什么也没发生。似乎它在等待什么。控制台没有回来。不得不用CTRL C杀死它。

我还试图通过

curl -XGET 'http://localhost:9200/_cat/indices?v'

与上述行为相同。

共有3个答案

杜祺
2023-03-14

集群/健康API可以做的远远超过大多数人看到的典型输出:

 $ curl -XGET 'localhost:9200/_cluster/health?pretty'

Elasticsearch中的大多数API可以采用各种参数来增加其输出。这也适用于集群健康API。

$ curl -XGET 'localhost:9200/_cluster/health?level=indices&pretty' | head -50
{
  "cluster_name" : "rdu-es-01",
  "status" : "green",
  "timed_out" : false,
  "number_of_nodes" : 9,
  "number_of_data_nodes" : 6,
  "active_primary_shards" : 1106,
  "active_shards" : 2213,
  "relocating_shards" : 0,
  "initializing_shards" : 0,
  "unassigned_shards" : 0,
  "delayed_unassigned_shards" : 0,
  "number_of_pending_tasks" : 0,
  "number_of_in_flight_fetch" : 0,
  "task_max_waiting_in_queue_millis" : 0,
  "active_shards_percent_as_number" : 100.0,
  "indices" : {
    "filebeat-6.5.1-2019.06.10" : {
      "status" : "green",
      "number_of_shards" : 3,
      "number_of_replicas" : 1,
      "active_primary_shards" : 3,
      "active_shards" : 6,
      "relocating_shards" : 0,
      "initializing_shards" : 0,
      "unassigned_shards" : 0
    },
    "filebeat-6.5.1-2019.06.11" : {
      "status" : "green",
      "number_of_shards" : 3,
      "number_of_replicas" : 1,
      "active_primary_shards" : 3,
      "active_shards" : 6,
      "relocating_shards" : 0,
      "initializing_shards" : 0,
      "unassigned_shards" : 0
    },
    "filebeat-6.5.1-2019.06.12" : {
      "status" : "green",
      "number_of_shards" : 3,
      "number_of_replicas" : 1,
      "active_primary_shards" : 3,
      "active_shards" : 6,
      "relocating_shards" : 0,
      "initializing_shards" : 0,
      "unassigned_shards" : 0
    },
    "filebeat-6.5.1-2019.06.13" : {
      "status" : "green",
      "number_of_shards" : 3,
$ curl -XGET 'localhost:9200/_cluster/health?level=shards&pretty' | head -50
{
  "cluster_name" : "rdu-es-01",
  "status" : "green",
  "timed_out" : false,
  "number_of_nodes" : 9,
  "number_of_data_nodes" : 6,
  "active_primary_shards" : 1106,
  "active_shards" : 2213,
  "relocating_shards" : 0,
  "initializing_shards" : 0,
  "unassigned_shards" : 0,
  "delayed_unassigned_shards" : 0,
  "number_of_pending_tasks" : 0,
  "number_of_in_flight_fetch" : 0,
  "task_max_waiting_in_queue_millis" : 0,
  "active_shards_percent_as_number" : 100.0,
  "indices" : {
    "filebeat-6.5.1-2019.06.10" : {
      "status" : "green",
      "number_of_shards" : 3,
      "number_of_replicas" : 1,
      "active_primary_shards" : 3,
      "active_shards" : 6,
      "relocating_shards" : 0,
      "initializing_shards" : 0,
      "unassigned_shards" : 0,
      "shards" : {
        "0" : {
          "status" : "green",
          "primary_active" : true,
          "active_shards" : 2,
          "relocating_shards" : 0,
          "initializing_shards" : 0,
          "unassigned_shards" : 0
        },
        "1" : {
          "status" : "green",
          "primary_active" : true,
          "active_shards" : 2,
          "relocating_shards" : 0,
          "initializing_shards" : 0,
          "unassigned_shards" : 0
        },
        "2" : {
          "status" : "green",
          "primary_active" : true,
          "active_shards" : 2,
          "relocating_shards" : 0,
          "initializing_shards" : 0,
          "unassigned_shards" : 0

API还具有多种等待选项,在这些选项中,它将等待各种状态更改,然后立即返回,或者在指定的超时之后返回。

慕才
2023-03-14

您可以使用elasticsearch提供的(CURL)和Cluster API检查elasticsearch集群健康状况:

$ curl -XGET 'localhost:9200/_cluster/health?pretty'

这将为您提供所需的状态和其他相关数据。

{
 "cluster_name" : "xxxxxxxx",
 "status" : "green",
 "timed_out" : false,
 "number_of_nodes" : 2,
 "number_of_data_nodes" : 2,
 "active_primary_shards" : 15,
 "active_shards" : 12,
 "relocating_shards" : 0,
 "initializing_shards" : 0,
 "unassigned_shards" : 0,
 "delayed_unassigned_shards" : 0,
 "number_of_pending_tasks" : 0,
 "number_of_in_flight_fetch" : 0
}
寿鸣
2023-03-14

要检查elasticsearch群集的运行状况,您需要使用

curl localhost:9200/_cat/health

更多关于cat API的信息。

我通常使用elasticsearch头插件来可视化它。

你可以在这里找到它的github项目。

很容易安装sudo$ES_HOME/bin/plugin-i mobz/elasticsearch head,然后你可以在你的浏览器中打开localhost:9200/plugin/head。

你应该有这样的东西:

 类似资料:
  • 我的elasticsearch集群“graylog2”健康状态显示为黄色,但在Web界面中显示为绿色。 我可以在Graylog web界面中看到以下几行。 “1索引管理总共26条消息,当前写活动索引为graylog2\u 0。 Elasticsearch群集为绿色。碎片:1个活动,0个初始化,0个重新定位,0个未分配“ 谁能回答我的一些问题吗 为什么logstash索引状态为黄色,即使其中只有很少

  • 我想写一个脚本来检查我们的elasticsearch集群(部署在kubernetes上)的运行状况 我进入运行elasticsearch主容器的pod中,运行以下命令: 如您所见,索引计数和运行状况检查命令都成功。但当我从外部运行这些命令时(我给elasticsearch集群一个公共endpoint) 只有index count命令成功,健康检查命令总是产生403禁止错误。 我已经从elastic

  • 本文向大家介绍如何监控 Elasticsearch 集群状态?相关面试题,主要包含被问及如何监控 Elasticsearch 集群状态?时的应答技巧和注意事项,需要的朋友参考一下 Marvel 让你可以很简单的通过 Kibana 监控 Elasticsearch。你可以实时查看你的集群健康状态和性能,也可以分析过去的集群、索引和节点指标。  

  • 我已经配置了一个网络负载平衡器,通过端口80将TCP流量路由到ECS群集 ECS群集正在运行ASP。Fargate配置中的NET Core 2.2 API任务。API的基本路径是<代码>http://ip_address:80/api/v1/ 首先,一切正常,我可以点击负载平衡器的DNS并将请求路由到适当的服务器。NET API路由 然而,最终NLB的健康检查失败,容器被排空,新的容器被替换。 有

  • 我们正试图通过启用SSL加密来保护我们的ElastiCache集群到Spring Boot流量。Spring Boot应用程序成功启动,但当它尝试在Eureka上注册时,Spring Boot Admin失败,出现异常: 设置: Spring Boot版本2.1.4。发布 工作流程: 应用程序启动并连接到ElastiCache群集 一段时间后,10-20秒<代码>Redis health chec