一、什么是Kibana  

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

 

 

  二、安装使用

    ①:下载Kibana https://www.elastic.co/cn/downloads/kibana

    ②:配置Kibana

      Open config/kibana.yml in an editor.

      Set elasticsearch.hosts to point at your Elasticsearch instance.

        默认情况下,Kibana 会连接运行在 localhost 上的 Elasticsearch 实例。如果需要连接不同的 Elasticsearch实例,可以修改 kibana.yml 配置文件中的 Elasticsearch URL 配置项并重启 Kibana

        如:elasticsearch.hosts: ["http://localhost:9200"]

    ③:运行

      Run bin/kibana (or bin\kibana.bat on Windows)

    ④:访问

      Point your browser at http://localhost:5601

        Kibana使用

 

    Kibana使用:

      ①:导入数据文件

      Kibana使用

      ②:预览并确认导入

      Kibana使用       

      ③:创建索引模式

      Kibana使用

      ④:在Discover中查看数据

      Kibana使用

 

     

      Kibana左侧的Toolbar主要分为一下几块功能:

        Discovery 发现:用于查看和搜索原始数据
        Visualize 可视化:用来创建图表、表格和地图等
        Dashboard:多个图表和合并为一个 Dashboard 仪表盘
        Timelion 时间线:用于分析时序数据,以二维图形的方式展示
        Dev Tools 开发工具:用于进行DSL查询、Query性能分析等
        Management 管理:主要用于创建 Index Patterns,ES中的索引在创建 Index Patterns 之后,才能在 Discover 中被搜索,在 Visualize 和 Dashboard 中制图。

 

 

 

  三、检索

     1、选择日期

    Kibana使用

     2、左侧栏目展示可用的字段列表:

    Kibana使用

 

  KQL(Kibana Query Language):

    1、根据具体字段检索

       ①:如果只想展示某个字段的内容,则在字段栏目上将鼠标悬停在类别字段上,然后单击 +          

       Kibana使用

       ②:根据字段内容检索

        如根据category字段 

      Kibana使用

 

         多个字段一起检索

      Kibana使用

 

         如检索价格字段>=60 且 category为 Women's Clothing 的数据:products.taxless_price >= 60 and category : Women's Clothing

 

      ③:通过filter:

        Kibana使用

         选择过滤的字段,和值的包含关系:

        Kibana使用        

         填入值,保存即可检索:

        Kibana使用

 

    2、检索字符串

      ①:匹配多个字符串,每个字段都会单独匹配。如:force and clean

      ②:匹配单个确切的字符串或者匹配字符串短语,用双引号括起来。如"force and clean"

 

 

   Luceue:

     1、根据字段查询

      限定字段全文搜索:field:value

      精确搜索:关键字加上双引号 filed:"value"

    2、通配符

      ? 匹配单个字符

      * 匹配0到多个字符

    3、模糊搜索

      ~:在一个单词后面加上~启用模糊搜索,可以搜到一些拼写错误的单词

    4、近似搜索

      在短语后面加上~,可以搜到被隔开或顺序不同的单词      

      "where select"~5 表示 select 和 where 中间可以隔着5个单词,可以搜到 select password from users where id=1

    5、范围搜索

      mod_date:[20020101 TO 20030101]:查找 mod_date 字段的值介于 20020101 和 20030101 之间的文档

      

   

  Dev Tools:

    Kinaba > Management > Dev Tools

    1、GET /   等价于 http://localhost:9200/,对应的curl为:curl -XGET "http://localhost:9200/"  

    2、创建一个索引及文档

      PUT index_name/_doc(type_name)/document_id

      {文档内容}       Kibana使用

    3、简单检索文档

     ①:GET /index_name/type_name/document_id 

      对应的curl:curl -X GET "localhost:9200/megacorp/employee/1?pretty"

      如 GET /megacorp/employee/1  的返回,_source属性里的是原始JSON文档

{
  "_index" : "megacorp",
  "_type" : "employee",
  "_id" : "1",
  "_version" : 1,
  "_seq_no" : 0,
  "_primary_term" : 1,
  "found" : true,
  "_source" : {
    "first_name" : "John",
    "last_name" : "Smith",
    "age" : 25,
    "about" : "I love to go rock climbing",
    "interests" : [
      "sports",
      "music"
    ]
  }
}

     ②:搜索索引下的全部文档:

      GET /megacorp/employee/_search

      curl -X GET "localhost:9200/megacorp/employee/_search?pretty"

      搜索结果放在了hit数组中,一个搜索默认返回10条结果

#! [types removal] Specifying types in search requests is deprecated.
{
  "took" : 12,
  "timed_out" : false,
  "_shards" : {
    "total" : 1,
    "successful" : 1,
    "skipped" : 0,
    "failed" : 0
  },
  "hits" : {
    "total" : {
      "value" : 3,
      "relation" : "eq"
    },
    "max_score" : 1.0,
    "hits" : [
      {
        "_index" : "megacorp",
        "_type" : "employee",
        "_id" : "1",
        "_score" : 1.0,
        "_source" : {
          "first_name" : "John",
          "last_name" : "Smith",
          "age" : 25,
          "about" : "I love to go rock climbing",
          "interests" : [
            "sports",
            "music"
          ]
        }
      },
      {
        "_index" : "megacorp",
        "_type" : "employee",
        "_id" : "2",
        "_score" : 1.0,
        "_source" : {
          "first_name" : "Jane",
          "last_name" : "Smith",
          "age" : 32,
          "about" : "I like to collect rock albums",
          "interests" : [
            "music"
          ]
        }
      },
      {
        "_index" : "megacorp",
        "_type" : "employee",
        "_id" : "3",
        "_score" : 1.0,
        "_source" : {
          "first_name" : "Douglas",
          "last_name" : "Fir",
          "age" : 35,
          "about" : "I like to build cabinets",
          "interests" : [
            "forestry"
          ]
        }
      }
    ]
  }
}
View Code

相关文章:

  • 2021-08-19
  • 2021-09-03
  • 2021-07-31
  • 2021-04-12
  • 2021-10-20
  • 2021-05-19
  • 2021-10-24
  • 2021-05-31
猜你喜欢
  • 2021-11-16
  • 2021-09-09
  • 2022-01-18
  • 2021-04-24
相关资源
相似解决方案