Kibana(安装及其简单crud)
概述
Kibana是一个针对Elasticsearch的开源数据分析及可视化平台,用来搜索、查看交互存储在Elasticsearch索引中的数 据。使用Kibana,可以通过各种图表进行高级数据分析及展示。
Kibana让海量数据更容易理解。它操作简单,基于浏览器的用户界面可以快速创建仪表板(dashboard)实时显示 Elasticsearch查询动态。
设置Kibana非常简单。无需编码或者额外的基础架构,几分钟内就可以完成Kibana安装并启动Elasticsearch索引监测
安装kibana
[root@localhost ~]# tar -zxvf kibana-6.4.0-linux-x86_64.tar.gz -C /usr [root@localhost ~]# cd /usr/kibana-6.4.0-linux-x86_64/ [root@localhost kibana-6.4.0-linux-x86_64]# vim config/kibana.yml # To allow connections from remote users, set this parameter to a non-loopback address. server.host: "192.168.xx.xx" # The URL of the Elasticsearch instance to use for all your queries. elasticsearch.url: "http://192.168.xx.xx:9200 [root@localhost kibana-6.4.0-linux-x86_64]# bin/kibana
启动测试:http://192.168.xx.xx:5601
查看集群信息
在Dev Tools中输入:GET /_cat/health?v 后,点击绿色运行按钮即可查看信息
信息如下:
集群状态(status)
Green(正常)
Yellow(正常,但是一些副本还没有分配)
Red(非正常)
查看集群中节点信息
GET /_cat/nodes?v
查看集群中索引信息
索引操作
创建索引
PUT /lhc
{ "acknowledged": true, #创建成功返回true "shards_acknowledged": true, "index": "lhc" }
删除索引
DELETE /lhc { "acknowledged": true }
创建类型
PUT /lhc # 创建index(lhc)并添加类型mapping(_doc) { "mappings": { "_doc": { "properties": { "title": { "type": "text" }, "name": { "type": "text" }, "age": { "type": "integer" }, "created": { "type": "date", "format": "strict_date_optional_time||epoch_millis" } } } } }
或者
POST /lhc/user # 创建index后,在指定index中添加类型mapping(user) { "user": { "properties": { "id": { "type": "text" }, "name": { "type": "text" }, "age": { "type": "integer" }, "created": { "type": "date", "format": "strict_date_optional_time||epoch_millis" } } } }
查看类型mapping
GET /lhc/_mapping/_doc # 语法:GET /索引名/_mapping/类型名 返回以下结果 { "lhc": { "mappings": { "_doc": { "properties": { "age": { "type": "integer" }, "created": { "type": "date" }, "name": { "type": "text" }, "title": { "type": "text" } } } } } }
新增单个文档
PUT /lhc/_doc/1 # put /索引名/类型名/i { #request body "name": "zs", "title": "张三", "age": 18, "created": "2018-12-25" }
或者
POST /lhc/_doc { #request body "name": "zs", "title": "张三", "age": 18, "created": "2018-12-25" } --------------------------------------------------------结果 { "_index": "lhc", "_type": "_doc", "_id": "KbOj6GcBVEuCC3JSh18Y",#ES自动生成的文档的id "_version": 1, "result": "created", "_shards": { "total": 2, "successful": 1, "failed": 0 }, "_seq_no": 0, "_primary_term": 1 }
查询单个文档
GET /lhc/_doc/LcydUHIBf3H1hS9U3-_N # 语法: GET /索引名/类型名/id { "_index": "lhc", "_type": "_doc", "_id": "LcydUHIBf3H1hS9U3-_N", "_version": 1, "found": true, "_source": { "name": "zs", "title": "张三", "age": 18, "created": "2016-07-15T12:58:17.136+0800" } }
修改单个文档:
POST /lhc/_doc/LcydUHIBf3H1hS9U3-_N { "name": "ls", "title": "李四", "age": 3, "created": "2016-07-15T12:58:17.136+0800" }
删除单个文档
DELETE /lhc/_doc/1 # 语法: DELETE /索引名/类型名/id