美文网首页
Kibana安装与使用

Kibana安装与使用

作者: IT小池 | 来源:发表于2020-01-06 19:38 被阅读0次

Kibana 是一个开源的分析和可视化平台,旨在与 Elasticsearch 合作。Kibana 提供搜索、查看和与存储在 Elasticsearch 索引中的数据进行交互的功能。开发者或运维人员可以轻松地执行高级数据分析,并在各种图表、表格和地图中可视化数据。
Kibana官网下载

安装

去官网下载后,直接解压,进入到 kibana-6.5.2-windows-x86_64\bin,双击kibana.bat启动(注意:必须先启动elasticsearch

注意:如果是链接本地的elasticsearch什么都不需要配置,直接双击启动Kibana,如果是远程连接,需要找到D:\web\kibana-6.5.2-windows-x86_64\config\kibana.yml文件中的

#elasticsearch.url: "http://localhost:9200"

放开注释,即可。
然后浏览器输入:http://localhost:5601/,默认端口5601。
访问之后可以看到管理界面,找到左侧菜单 Dev Tools即可进行管理所有索引

创建索引结构(静态映射方式,即规定索引结构)

如:格式
请求方式PUT

PUT /索引库名
{
   "mappings": {
       "类型名称":{           
          "properties": {
                "字段名": {
                  "type": "类型",
                  "index": true,
                  "store": true,
                  "analyzer": "分词器"
           }
       }
   }
}
  • 类型名称:就是前面将的 type的概念,类似于数据库中的不同表字段名:任意填写 ,可以指定许多属性,例如:
    • type :类型,可以是text、long、short、date、integer、object等
    • index :是否索引,默认为true
    • store :是否单独存储,默认为false ,一般内容比较多的字段设置成true,可提升查询性能
    • analyzer :分词器

注意:如果需要分词一定用 text类型,如果需要做一些聚合运算则选择 keyword 类型
如:在Kibana访问后的界面中找到 Dev Tools中的console中,写如下内容

#创建索引结构 testindex_abc是索引名称   doc是类型名称
####注意:如果需要分词一定用 text类型,如果需要做一些聚合运算则选择 keyword 类型
PUT testindex_abc
{
  "mappings": {
    "doc":{ 
      "properties":{
        "name":{
          "type":"text",
          "analyzer":"ik_smart"
        },
        "price":{
          "type":"integer"
        },
        "image":{
          "type":"text"
        },
        "createTime":{
          "type":"date"
        },
        "attrId":{
          "type":"text"
        },
        "categoryName":{
          "type":"keyword"
        },
        "brandName":{
          "type":"keyword"
        },
        "details":{
          "type":"object"
        },
        "stock":{
          "type":"integer"
        }
      }
    }
  }
}

执行,看到

#! Deprecation: the default number of shards will change from [5] to [1] in 7.0.0; if you wish to continue using the default of [5] shards, you must manage this on the create index request or with an index template
{
  "acknowledged" : true,
  "shards_acknowledged" : true,
  "index" : "testindex_test"
}

表示创建索引结构成功。接下来,就向索引结构中创建文档,并指定id,通过PUT请求(注意:不指定id,是通过POST请求提交),可以向一个已经存在的索引库中添加数据

PUT / 索引库名/类型/id值
{
    "key":"value"
}

数据

PUT sku/doc/1
{
  "name":"小米电视",
  "price":1000,
  "spuId":1010101011,
  "createTime":"2019‐03‐01",
  "categoryName":"电视",
  "brandName":"小米",
  "saleNum":10102,
  "commentNum":1331,
  "spec":{
    "网络制式":"移动4G",
    "屏幕尺寸":"4.5"
  }
}

相关文章

网友评论

      本文标题:Kibana安装与使用

      本文链接:https://www.haomeiwen.com/subject/zrzkactx.html