Elasticsearch 学习笔记Day 31

85 阅读2分钟

hi,我是蛋挞,一个初出茅庐的后端开发,希望可以和大家共同努力、共同进步!


开启掘金成长之旅!这是我参与「掘金日新计划 · 4 月更文挑战」的第 15 天,点击查看活动详情

  • 起始标记->用Kibana进行数据可视化分析(4讲):「80 | 使用Index Pattern配置数据」
  • 结尾标记->用Kibana进行数据可视化分析(4讲):「83 | 构建Dashboard」

使用Index Pattern配置数据

CodeDemo


localhost:5601/status




PUT /logstash-2015.05.18
{
  "mappings": {
    "properties": {
      "geo": {
        "properties": {
          "coordinates": {
            "type": "geo_point"
          }
        }
      }
    }
  }
}



PUT /logstash-2015.05.19
{
  "mappings": {
    "properties": {
      "geo": {
        "properties": {
          "coordinates": {
            "type": "geo_point"
          }
        }
      }
    }
  }
}


PUT /logstash-2015.05.20
{
  "mappings": {
    "properties": {
      "geo": {
        "properties": {
          "coordinates": {
            "type": "geo_point"
          }
        }
      }
    }
  }
}

# For Mac & Windows
curl -H 'Content-Type: application/x-ndjson' -XPOST 'localhost:9200/_bulk?pretty' --data-binary @logs.jsonl

curl -H 'Content-Type: application/x-ndjson' -XPOST 'localhost:9200/bank/account/_bulk?pretty' --data-binary @accounts.json


#For Windows
Invoke-RestMethod "http://localhost:9200/_bulk?pretty" -Method Post -ContentType 'application/x-ndjson' -InFile "logs.jsonl"



GET /_cat/indices?v

本节知识小节

通过两个具体的实例导入了一些测试的数据,并且在Kinbana上为这些测试数据创建了Index Pattern,在Kinbana上做一些图标的展示和数据的分析,都需要先去创建Index Pattern。

使用Kibana Discover探索数据

CodeDemo

设置时间过滤器
搜索你的数据
根据字段进行过滤
查看文档数据
查看文档上下文
暂时字段数据统计
Save Query

本节知识小节

对Discover做了一个详细的讲解,通过Discover URL可以很方便的对Index Pattern数据进行探索,方便更好的理解索引当中的数据,方便日后做图形化展示。

基本可视化组件介绍

image.png image.pngimage.png image.png

CodeDemo


PUT /shakespeare
{
  "mappings": {
    "properties": {
    "speaker": {"type": "keyword"},
    "play_name": {"type": "keyword"},
    "line_id": {"type": "integer"},
    "speech_number": {"type": "integer"}
    }
  }
}


# For Mac & Windows
curl -H 'Content-Type: application/x-ndjson' -XPOST 'localhost:9200/bank/account/_bulk?pretty' --data-binary @accounts.json
curl -H 'Content-Type: application/x-ndjson' -XPOST 'localhost:9200/shakespeare/_bulk?pretty' --data-binary @shakespeare.json

#For Windows
Invoke-RestMethod "http://localhost:9200/bank/account/_bulk?pretty" -Method Post -ContentType 'application/x-ndjson' -InFile "accounts.json"
Invoke-RestMethod "http://localhost:9200/shakespeare/_bulk?pretty" -Method Post -ContentType 'application/x-ndjson' -InFile "shakespeare.json"

本节知识小节

学习了如何为Kinbana创建一些可视化组件,通过可视化组件可以更好的使用图形化了解我们的数据。

构建Dashboard

Demo

  • 安装配置
  • 配置 Kibana Dashboard
  • 运行
  • 查看 Dashboard
    • Dashboard 是一组相关主题的可视化组件
    • Dashboard 的设计准则(Resize)

image.png image.png 可以很方便的执行删除,拖拉等操作。 image.png 通过主界面也可以很快的进入Dashboards image.png 可以通过新增组件来展示到主界面上。

CodeDemo

- 创建仪表潘
- 加载仪表盘
- 共享仪表盘

本节知识小节

演示了如何创建简单的Dashboard,创建Dashboard中有很多需要注意的地方,比如如何创建相关的可视化组件最终组织到一起,通过导入数据学习。


此文章为4月Day15学习笔记,内容来源于极客时间《Elasticsearch 核心技术与实战》