kibana 开发工具介绍

kibana上查看es集群节点信息

get /_cat/nodes?v  

ip        heap.percent ram.percent cpu load_1m load_5m load_15m node.role master name
127.0.0.1           23          97   1    0.07    0.04     0.05 mdi       *      ES

  查看kibana_sample_data_ecommerce索引的相关信息

GET kibana_sample_data_ecommerce


{
  "kibana_sample_data_ecommerce" : {
    "aliases" : { },
    "mappings" : {
      "properties" : {
        "category" : {
          "type" : "text",
          "fields" : {
            "keyword" : {
              "type" : "keyword"
            }
          }
        },
        "currency" : {
          "type" : "keyword"
        },
        "customer_birth_date" : {
          "type" : "date"
        },
        "customer_first_name" : {
          "type" : "text",
          "fields" : {
            "keyword" : {
              "type" : "keyword",
              "ignore_above" : 256
            }
          }
        },
        "customer_full_name" : {
          "type" : "text",
          "fields" : {
            "keyword" : {
              "type" : "keyword",
              "ignore_above" : 256
            }
          }
        },
        "customer_gender" : {
          "type" : "keyword"
        },
        "customer_id" : {
          "type" : "keyword"
        },
        "customer_last_name" : {
          "type" : "text",
          "fields" : {
            "keyword" : {
              "type" : "keyword",
              "ignore_above" : 256
            }
          }
        },
        "customer_phone" : {
          "type" : "keyword"
        },
        "day_of_week" : {
          "type" : "keyword"
        },
        "day_of_week_i" : {
          "type" : "integer"
        },
        "email" : {
          "type" : "keyword"
        },
        "geoip" : {
          "properties" : {
            "city_name" : {
              "type" : "keyword"
            },
            "continent_name" : {
              "type" : "keyword"
            },
            "country_iso_code" : {
              "type" : "keyword"
            },
            "location" : {
              "type" : "geo_point"
            },
            "region_name" : {
              "type" : "keyword"
            }
          }
        },
        "manufacturer" : {
          "type" : "text",
          "fields" : {
            "keyword" : {
              "type" : "keyword"
            }
          }
        },
        "order_date" : {
          "type" : "date"
        },
        "order_id" : {
          "type" : "keyword"
        },
        "products" : {
          "properties" : {
            "_id" : {
              "type" : "text",
              "fields" : {
                "keyword" : {
                  "type" : "keyword",
                  "ignore_above" : 256
                }
              }
            },
            "base_price" : {
              "type" : "half_float"
            },
            "base_unit_price" : {
              "type" : "half_float"
            },
            "category" : {
              "type" : "text",
              "fields" : {
                "keyword" : {
                  "type" : "keyword"
                }
              }
            },
            "created_on" : {
              "type" : "date"
            },
            "discount_amount" : {
              "type" : "half_float"
            },
            "discount_percentage" : {
              "type" : "half_float"
            },
            "manufacturer" : {
              "type" : "text",
              "fields" : {
                "keyword" : {
                  "type" : "keyword"
                }
              }
            },
            "min_price" : {
              "type" : "half_float"
            },
            "price" : {
              "type" : "half_float"
            },
            "product_id" : {
              "type" : "long"
            },
            "product_name" : {
              "type" : "text",
              "fields" : {
                "keyword" : {
                  "type" : "keyword"
                }
              },
              "analyzer" : "english"
            },
            "quantity" : {
              "type" : "integer"
            },
            "sku" : {
              "type" : "keyword"
            },
            "tax_amount" : {
              "type" : "half_float"
            },
            "taxful_price" : {
              "type" : "half_float"
            },
            "taxless_price" : {
              "type" : "half_float"
            },
            "unit_discount_amount" : {
              "type" : "half_float"
            }
          }
        },
        "sku" : {
          "type" : "keyword"
        },
        "taxful_total_price" : {
          "type" : "half_float"
        },
        "taxless_total_price" : {
          "type" : "half_float"
        },
        "total_quantity" : {
          "type" : "integer"
        },
        "total_unique_products" : {
          "type" : "integer"
        },
        "type" : {
          "type" : "keyword"
        },
        "user" : {
          "type" : "keyword"
        }
      }
    },
    "settings" : {
      "index" : {
        "number_of_shards" : "1",
        "auto_expand_replicas" : "0-1",
        "provided_name" : "kibana_sample_data_ecommerce",
        "creation_date" : "1573016765747",
        "number_of_replicas" : "0",
        "uuid" : "O7wX0YeWRxuniFTLuDWJfA",
        "version" : {
          "created" : "7010099"
        }
      }
    }
  }
}

  查看kibana_sample_data_ecommerce索引文档总数

GET kibana_sample_data_ecommerce/_count

{
  "count" : 4675,
  "_shards" : {
    "total" : 1,
    "successful" : 1,
    "skipped" : 0,
    "failed" : 0
  
}

  查看kibana_sample_data_ecommerce索引的前10条文档;了解文档格式

GET kibana_sample_data_ecommerce/_search

  对索引名字(kibana)进行通配符的查询

GET /_cat/indices/kibana*?v&s=index


health status index                        uuid                   pri rep docs.count docs.deleted store.size pri.store.size
green  open   kibana_sample_data_ecommerce O7wX0YeWRxuniFTLuDWJfA   1   0       475            0      5.1mb          5.1mb
green  open   kibana_sample_data_flights   YnASLIEoROG6b7mFnnx2DQ   1   0      13059            0      6.3mb          6.3mb
green  open   kibana_sample_data_logs      TUmwnhpKSkSAKfXptgNY4A   1   0      14005            0     11.2mb         11.2mb

  查看状态为绿色的索引

GET /_cat/indices?v&health=green


health status index                        uuid                   pri rep docs.count docs.deleted store.size pri.store.size
green  open   .kibana_task_manager         urh_dFyVTnuweARB0GvYdw   1   0          2            9     25.1kb         25.1kb
green  open   kibana_sample_data_logs      TUmwnhpKSkSAKfXptgNY4A   1   0      14005            0     11.2mb         11.2mb
green  open   .kibana_1                    lIWHe_2HT3ujqHcWG-Vt3w   1   0        140            0        1mb            1mb
green  open   kibana_sample_data_ecommerce O7wX0YeWRxuniFTLuDWJfA   1   0       4675            0      5.1mb          5.1mb
green  open   kibana_sample_data_flights   YnASLIEoROG6b7mFnnx2DQ   1   0      13059            0      6.3mb          6.3mb

  按照文档的个数进行索引排序

GET /_cat/indices?v&s=docs.count:desc




health status index                        uuid                   pri rep docs.count docs.deleted store.size pri.store.size
green  open   kibana_sample_data_logs      TUmwnhpKSkSAKfXptgNY4A   1   0      14005            0     11.2mb         11.2mb
green  open   kibana_sample_data_flights   YnASLIEoROG6b7mFnnx2DQ   1   0      13059            0      6.3mb          6.3mb
yellow open   movies                       _S2PT287T_aP0QN1S1GvAw   1   1       9743            0      1.3mb          1.3mb
green  open   kibana_sample_data_ecommerce O7wX0YeWRxuniFTLuDWJfA   1   0       4675            0      5.1mb          5.1mb
green  open   .kibana_1                    lIWHe_2HT3ujqHcWG-Vt3w   1   0        140            0        1mb            1mb
green  open   .kibana_task_manager         urh_dFyVTnuweARB0GvYdw   1   0          2            9     25.1kb         25.1kb

  查看以kibana开头索引的health,index,pri,rep,docs,count,mt字段

GET /_cat/indices/kibana*?pri&v&h=health,index,pri,rep,docs,count,mt


health index                        pri rep mt pri.mt
green  kibana_sample_data_flights     1   0  1      1
green  kibana_sample_data_ecommerce   1   0  0      0
green  kibana_sample_data_logs        1   0  1      1

  查看每条索引占得空间

GET /_cat/indices?v&h=i,tm&s=tm:desc

i                                 tm
kibana_sample_data_ecommerce 161.8kb
kibana_sample_data_logs       54.6kb
.kibana_1                     47.5kb
kibana_sample_data_flights    37.7kb
movies                        25.1kb
.kibana_task_manager           4.4kb

  查看集群状态

GET /_cluster/health


{
  "cluster_name" : "elasticsearch",
  "status" : "yellow",
  "timed_out" : false,
  "number_of_nodes" : 1,
  "number_of_data_nodes" : 1,
  "active_primary_shards" : 6,
  "active_shards" : 6,
  "relocating_shards" : 0,
  "initializing_shards" : 0,
  "unassigned_shards" : 1,
  "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" : 85.71428571428571
}

  查看集群分片信息

GET /_cat/shards



.kibana_task_manager         0 p STARTED        2 25.1kb 127.0.0.1 ES
movies                       0 p STARTED     9743  1.3mb 127.0.0.1 ES
movies                       0 r UNASSIGNED                        
kibana_sample_data_ecommerce 0 p STARTED     4675  5.1mb 127.0.0.1 ES
.kibana_1                    0 p STARTED      140    1mb 127.0.0.1 ES
kibana_sample_data_flights   0 p STARTED    13059  6.3mb 127.0.0.1 ES
kibana_sample_data_logs      0 p STARTED    14005 11.2mb 127.0.0.1 ES

  自动生成文档的ID

POST chenxij/_doc
{
  "user":"kk",
    "data":"902",
    "message":"tgfd"
}


{
  "_index" : "chenxi",
  "_type" : "_doc",
  "_id" : "UnaqP24B9uEN4vPi-rFS",
  "_version" : 1,
  "result" : "created",
  "_shards" : {
    "total" : 2,
    "successful" : 1,
    "failed" : 0
  },
  "_seq_no" : 3,
  "_primary_term" : 1
}

   指定ID如果ID存在就报错

POST cx/_doc/1?op_type=create
{
  "trc":"kk",
    "hjj":"665",
    "qwsx":"ugfd"
}



{
  "error": {
    "root_cause": [
      {
        "type": "version_conflict_engine_exception",
        "reason": "[1]: version conflict, document already exists (current version [1])",
        "index_uuid": "g-E8rbQoSomDGTtk3uYbmw",
        "shard": "0",
        "index": "cx"
      }
    ],
    "type": "version_conflict_engine_exception",
    "reason": "[1]: version conflict, document already exists (current version [1])",
    "index_uuid": "g-E8rbQoSomDGTtk3uYbmw",
    "shard": "0",
    "index": "cx"
  },
  "status": 409
}

  查看文档

GET chenxi/_doc/1



{
  "_index" : "chenxi",
  "_type" : "_doc",
  "_id" : "1",
  "found" : false
}

  更新文档添加字段

POST cx/_update/1/
{
  "doc":{
       "cgfd":"tgfgygy",
       "ertyui":"rtyu"
    }
}


{
  "_index" : "cx",
  "_type" : "_doc",
  "_id" : "1",
  "_version" : 2,
  "result" : "noop",
  "_shards" : {
    "total" : 0,
    "successful" : 0,
    "failed" : 0
  }
}

  查看更新后的文档

GET cx/_doc/1




{
  "_index" : "cx",
  "_type" : "_doc",
  "_id" : "1",
  "_version" : 2,
  "_seq_no" : 4,
  "_primary_term" : 1,
  "found" : true,
  "_source" : {
    "trc" : "kk",
    "hjj" : "665",
    "qwsx" : "ugfd",
    "ertyui" : "rtyu",
    "cgfd" : "tgfgygy"
  }
}

  BULK 的API 是一次请求多次调用的API,减少网络的绘画建立

草都可以从石头缝隙中长出来更可况你呢
原文地址:https://www.cnblogs.com/rdchenxi/p/11808237.html