ELK你这么学就对了—Kibana篇
一、什么是Kibana
Kibana是ELK中K的全称,那它是用来干什么的呢?Kibana有非常丰富的可视化分析组件,比如基本图表、VEGA图表、Canvas图表、表格、时序数据图,还有仪表板让你把各种图表汇聚到一起做可视化分析,下面作者就和大家一起走进Kibana。
在Kibana的官网最长看到的一句话就是一图胜过千万行日志那kibana到底有哪些功能?官方的准确解释如下:
1.1 主要功能
Kibana Lens
时序可视化生成器
地理空间分析
图表
指标
数据表
标签云图
Vega(定制)
Machine Learning
1.2 常用功能详解
Kibana Lens
Kibana Lens 是一个直观易用的 UI,能够通过拖放体验简化数据可视化过程。无论想探索数十亿条日志,还是希望从网站流量中找出趋势,通过 Lens,您只需轻点几下鼠标便可从数据中收获洞见,之前无需拥有任何 Kibana 经验!
时序可视化生成器
时序可视化生成器 (TSVB) 是一个时序数据可视化工具,利用了 Elasticsearch 聚合框架的全部威力,可将无数的聚合和管道聚合整合在一起,从而以富有成效的方式展示复杂数据
地理空间分析
对 Elastic Stack 的很多用户而言,“哪里”是一个至关重要的问题。无论您希望保护自己的网络免受攻击,还是调查为何特定地点的应用程序响应时间长,或者只是打个网约车回家,地理空间数据和搜索都发挥着重要的作用
图表
借助线状图、面积图和柱形图,您能够在 X/Y 轴上绘制数据。热点图能够以图形方式展示数据,在热点图中,矩阵中所包含的单独值会以颜色或渐变色表示。饼图还有一种变体,即包含两个圆的环形图,在环形图上,被分割的不再是饼片,而是环形片。
Machine Learning
二、Kibana如何安装
讲了那么多Kibana的功能后,如何安装Kibana应该才是很多朋友关心的。不用着急,打开kibana的官方文档,找到对应的下载页面
2.1 下载与安装(Kibana 6.8.5)
https://artifacts.elastic.co/downloads/kibana/kibana-6.8.5-linux-x86_64.tar.gz
安装步骤
wget https://artifacts.elastic.co/downloads/kibana/kibana-6.8.5-linux-x86_64.tar.gz
tar -zxvf kibana-6.8.5-linux-x86_64.tar.gz -C /usr/local/
useradd -s /bin/nologin kibana
mkdir -p /usr/local/kibana
ln -s /usr/local/kibana-6.8.5-linux-x86_64 /usr/local/kibana
chown -R kibana:kibana /usr/local/kibana-6.8.5-linux-x86_64 /usr/local/kibana
1
2
3
4
5
6
修改配置文件
vim /usr/local/kibana/kibana.yml
server.port: 5601
server.host: "192.168.248.231"
server.name: "zxb_kibana_6.8.5"
elasticsearch.url: ["http://192.168.248.231:9201"]
kibana.index: ".kibana"
elasticsearch.username: "elastic"
elasticsearch.password: "paic1234A"
xpack.security.enabled: true
xpack.security.encryptionKey: "something_at_least_32_characters"
1
2
3
4
5
6
7
8
9
启动kibana
/usr/local/kabana/bin/kabana &
1
启动日志
log [09:17:44.693] [info][status][plugin:[email protected]] Status changed from red to green - Ready
log [09:17:44.697] [info][status][plugin:[email protected]] Status changed from red to green - Ready
log [09:17:44.703] [info][status][plugin:[email protected]] Status changed from red to green - Ready
log [09:17:44.706] [info][status][plugin:[email protected]] Status changed from red to green - Ready
log [09:17:44.707] [info][status][plugin:[email protected]] Status changed from red to green - Ready
log [09:17:44.710] [info][status][plugin:[email protected]] Status changed from red to green - Ready
log [09:17:44.712] [info][status][plugin:[email protected]] Status changed from red to green - Ready
log [09:17:44.714] [info][status][plugin:[email protected]] Status changed from red to green - Ready
log [09:17:44.717] [info][status][plugin:[email protected]] Status changed from red to green - Ready
log [09:17:44.720] [info][status][plugin:[email protected]] Status changed from red to green - Ready
log [09:17:44.722] [info][status][plugin:[email protected]] Status changed from red to green - Ready
log [09:17:44.723] [info][status][plugin:[email protected]] Status changed from red to green - Ready
log [09:17:44.724] [info][status][plugin:[email protected]] Status changed from red to green - Ready
log [09:17:44.725] [info][status][plugin:[email protected]] Status changed from red to green - Ready
log [09:17:44.726] [info][kibana-monitoring][monitoring-ui] Starting monitoring stats collection
log [09:17:44.749] [info][status][plugin:[email protected]] Status changed from red to green - Ready
log [09:17:44.832] [info][license][xpack] Imported license information from Elasticsearch for the [monitoring] cluster: mode: basic | status: active
log [09:17:44.996] [info][status][plugin:[email protected]] Status changed from red to green - Ready
log [09:17:47.248] [info][status][plugin:[email protected]] Status changed from red to green - Ready
log [09:17:49.092] [warning][browser-driver][reporting] Enabling the Chromium sandbox provides an additional layer of protection.
log [09:17:49.095] [warning][reporting] Generating a random key for xpack.reporting.encryptionKey. To prevent pending reports from failing on restart, please set xpack.reporting.encryptionKey in kibana.yml
log [09:17:49.235] [info][status][plugin:[email protected]] Status changed from uninitialized to green - Ready
log [09:17:49.483] [warning][reporting] The Reporting plugin encountered issues launching Chromium in a self-test. You may have trouble generating reports: [object Object]
log [09:17:49.484] [warning][reporting] See Chromium's log output at "/usr/local/kibana-6.8.5-linux-x86_64/data/headless_shell-linux/chrome_debug.log"
log [09:17:50.170] [warning][task_manager] Task vis_telemetry "oss_telemetry-vis_telemetry" failed in attempt to run: [version_conflict_engine_exception] [_doc][oss_telemetry-vis_telemetry]: version conflict, required seqNo [7], primary term [4]. current document has seqNo [8] and primary term [4], with { index_uuid="6VOprxodR1WJkMgm9Mt0yw" & shard="0" & index=".kibana_task_manager" }
log [09:17:50.381] [info][listening] Server running at http://192.168.248.231:5601
log [09:17:50.410] [info][status][plugin:[email protected]] Status changed from red to green - Ready
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
其他安装方式
https://www.elastic.co/guide/en/kibana/6.8/install.html
三、Kibana该怎么用
Kibana是安装完毕了,那我们要怎么使用它呢?下面就对Kibana常用模块进行讲解
3.1导入数据
如下图,进入Kibana首先需要的是把测试数据导入ES中进行模拟
测试数据主要类型
电商数据
航班数据
简单的web日志
3.2 Dev Tools简介
DevTools 作为Kibana的一个功能模块,主要有三种Console,Search Profiler,Grok Debugger.我们主要讲一下最长见的Console.
各类查询
快捷键
Console提供了一些快捷键,来提高使用效率。
快捷键 | 说明 |
---|---|
ctrl/cmd + enter | 提交请求 |
ctrl/cmd + alt/option + L | 叠起/打开当前代码 |
ctrl/cmd + / | 打开api对应官当 |
ctrl/cmd + up/down | 跳到上一个或下一个执行块 |
ctrl/cmd + I | 缩进格式 |
esc | 关闭当前提示框 |
用户角色权限管控
除了以上模块,Kibana的Management模块也是很有用的,这个模块可以让你更好地管理用户和角色,为你打造最小化的用户和权限,具体使用,本文就不详细讲解
四、Kibana的插件说明
Kibana和Elasticsearch一样也是有一些开源插件的,具体如下图:
4.1 插件介绍
https://www.elastic.co/guide/en/kibana/current/known-plugins.html
4.2 插件安装
# 安装 kibana 插件
bin/kibana-plugin install plugin_location
# 查看已安装的 kibana 插件
bin/kibana-plugin list
# 异常已经安装的 kibana 插件
bin/kibana remove plugin_name
1
2
3
4
5
6
其实Kibana是无状态的,入门也并不难,本文将Kibana的基础都讲解一遍,希望对你有用,有空点个赞,原创不易
参考
https://www.elastic.co/guide/en/kibana/6.8/install.html
https://www.elastic.co/guide/en/kibana/6.8/known-plugins.html
https://www.elastic.co/guide/en/kibana/current/using-kibana-with-security.html