LoginSignup
16
5

More than 3 years have passed since last update.

Elasticsearchで使うcurlのコマンド一覧

Last updated at Posted at 2020-05-28

Elasticsaearchでよく使うcurlコマンドをいつも探しているのでメモ

前提

$HOSTNAMEでcurlができる状態

参考にしたページ

コマンド

elasticsearchの基本情報を取得

$ curl http://$HOSTNAME:9200
{
  "name" : "node名",
  "cluster_name" : "クラスタ名",
  "cluster_uuid" : "クラスタuuid",
  "version" : {
    "number" : "6.7.1",
    "build_flavor" : "default",
    "build_type" : "rpm",
    "build_hash" : "2f32220",
    "build_date" : "2019-04-02T15:59:27.961366Z",
    "build_snapshot" : false,
    "lucene_version" : "7.7.0",
    "minimum_wire_compatibility_version" : "5.6.0",
    "minimum_index_compatibility_version" : "5.0.0"
  },
  "tagline" : "You Know, for Search"
}

クラスタのhealthチェック

  • statusがgreenが正常
  • number_of_nodesはnodeの数。クラスタを組んでいる場合は対象クラスタの数と一致しているか確認する
curl http://$HOSTNAME:9200/_cluster/health?pretty=true
{
  "cluster_name" : "クラスタ名",
  "status" : "green",
  "timed_out" : false,
  "number_of_nodes" : 3,
  "number_of_data_nodes" : 3,
  "active_primary_shards" : 0,
  "active_shards" : 0,
  "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
}

クラスタ間の情報の確認

  • となっているのがmaster node
$ curl http://$HOSTNAME:9200/_cat/nodes
xx.xxx.xxx.xxx 19 32 0 0.00 0.02 0.05 mdi - {cluster_name}
xx.xxx.xxx.xxx 40 63 3 0.01 0.07 0.07 mdi - {cluster_name}
xx.xxx.xxx.xxx 13 31 1 0.00 0.02 0.05 mdi * {cluster_name}

indexの一覧を取得する

$ curl http://$HOSTNAME:9200/_aliases?pretty
{
  "empty" : {
    "aliases" : { }
  },
  "index名1" : {
    "aliases" : { }
  },
  "index名2" : {
    "aliases" : { }
  }
  .
  .
}

インデックスのドキュメント数を取得

$ curl http://$HOSTNAME:9200/_cat/count/{index}

{timestamp} 07:18:46 {ドキュメント数}

x-packでSSL通信で取得する時のコマンド

$ curl -u elastic:<パスワード> https://$HOSTNAME:9200 --insecure
{
  "name" : "node名",
  "cluster_name" : "クラスタ名",
  "cluster_uuid" : "クラスタuuid",
  "version" : {
    "number" : "6.7.1",
    "build_flavor" : "default",
    "build_type" : "rpm",
    "build_hash" : "2f32220",
    "build_date" : "2019-04-02T15:59:27.961366Z",
    "build_snapshot" : false,
    "lucene_version" : "7.7.0",
    "minimum_wire_compatibility_version" : "5.6.0",
    "minimum_index_compatibility_version" : "5.0.0"
  },
  "tagline" : "You Know, for Search"
}
16
5
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
16
5