kibana的简单使用

2019-04-08  本文已影响0人  Zhang小二

kibana简介

通过kibana,能够对elasticsearch中的数据进行可视化,图形支持:柱状图、线状图、饼图、旭日图等。由于生产环境中已经嵌入一些kibana生成的视图,所以对kibana作一些简单的了解,本文是简单探索的一些记录,详细配置还是看官方文档来的方便。

一、安装与配置

测试环境:win10

1.1 安装

win版本直接下载压缩版解压即可。

1.2 配置

配置文件位置:$KIBANA_HOME/config/kibana.yml
初始尝试,只需要关注以下几个参数:

elasticsearch.url: "http://localhost:9200" #指定查询es的url
elasticsearch.hosts: "http://localhost:9200" #此处列出的所有节点必须位于同一集群
elasticsearch.username: #es有身份验证时,需要配置
elasticsearch.password: #es有身份验证时,需要配置
server.host: "localhost" #提供服务的ip
server.port: 5601 #提供服务的端口

kibana本身支持的配置还是比较多的,具体作用参见:

https://www.elastic.co/guide/en/kibana/current/settings.html

1.3 启用kibana

启动kibana之前,需要先启动elasticsearch,并且需要保证两个组件的版本一致,当前测试使用的是6.7.1版本。
启动命令:

./kibana.bat
启动日志很多,末尾日志为:
  log   [14:10:23.183] [info][listening] Server running at http://localhost:5601
  log   [14:10:23.284] [info][status][plugin:spaces@6.7.1] Status changed from yellow to green - Ready

1.4 检查kibana状态

方法一:通过浏览器访问:http://localhost:5601/status
方法二:直接使用curl请求http://localhost:5601/api/status

二、可视化配置

2.1 加载测试数据

官网提供了几个测试示例的数据,按照官网所述的方法加载到es中。
https://www.elastic.co/guide/en/kibana/current/tutorial-load-dataset.html

先建立mapping,再将测试示例的数据加载到es中。
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/doc/_bulk?pretty' --data-binary @shakespeare_6.0.json
curl -H 'Content-Type: application/x-ndjson' -XPOST 'localhost:9200/_bulk?pretty' --data-binary @logs.jsonl

2.2 定义自己的索引模式

Management>>Index Patterns >>Add New
根据索引字段中是否包含时间序列数据,选择“Index contains time-based events”。


image.png

2.3 数据探索(Discover)

在Discover界面,主要验证定义的检索条件是否能够检索到数据。


2.4 可视化数据

使用示例数据简单加了饼形图与柱状图,效果如下:


image.png
image.png

2.5 简单仪表盘的添加

image.png

三、监控界面

image.png
image.png

总结

kibana还是挺简单易用的,支持的表格类型非常多,并且随着elasticsearch的广泛使用,kibana应用的场景肯定会越来越多,当然此次只是最简单的使用,后期再通过项目实践深化学习。

上一篇下一篇

猜你喜欢

热点阅读