更新 Kibana.md

This commit is contained in:
wxin 2025-05-04 22:46:35 +08:00
parent abcdf0202f
commit b911c61aba

324
Kibana.md
View File

@ -1,162 +1,162 @@
<h2><center>Kibana</center></h2> <h2><center>Kibana</center></h2>
------ ------
## 一:基本概念 ## 一:基本概念
### 1. Kibana 简介 ### 1. Kibana 简介
Kibana 是一个开源的数据分析和可视化平台,它是 Elastic Stack包括 Elasticsearch、Logstash、Kibana 和 Beats的一部分主要用于对 Elasticsearch 中的数据进行搜索、查看、交互操作。 Kibana 是一个开源的数据分析和可视化平台,它是 Elastic Stack包括 Elasticsearch、Logstash、Kibana 和 Beats的一部分主要用于对 Elasticsearch 中的数据进行搜索、查看、交互操作。
### 2. Kibana 功能 ### 2. Kibana 功能
- 数据可视化Kibana 提供了丰富的数据可视化选项,如柱状图、线图等,帮助用户以图形化的方式理解数据 - 数据可视化Kibana 提供了丰富的数据可视化选项,如柱状图、线图等,帮助用户以图形化的方式理解数据
- 数据探索Kibana 提供了强大的数据探索功能,用户可以通过 Kibana 的界面进行数据筛选和排序 - 数据探索Kibana 提供了强大的数据探索功能,用户可以通过 Kibana 的界面进行数据筛选和排序
- 仪表盘:用户可以将多个可视化组件组合在一起,创建交互式的仪表盘,用于实时监控数据 - 仪表盘:用户可以将多个可视化组件组合在一起,创建交互式的仪表盘,用于实时监控数据
- 机器学习Kibana 还集成了 Elasticsearch 的机器学习功能,可以用于异常检测、预测等任务 - 机器学习Kibana 还集成了 Elasticsearch 的机器学习功能,可以用于异常检测、预测等任务
- 定制和扩展Kibana 提供了丰富的 API 和插件系统,用户可以根据自己的需求定制和扩展 Kibana - 定制和扩展Kibana 提供了丰富的 API 和插件系统,用户可以根据自己的需求定制和扩展 Kibana
## 二:安装部署 ## 二:安装部署
### 1. 获取安装包 ### 1. 获取安装包
对应Elasticsearch版本获取Kibana的安装包 对应Elasticsearch版本获取Kibana的安装包
官网获取:[Past Releases of Elastic Stack Software | Elastic](https://www.elastic.co/downloads/past-releases#kibana) 官网获取:[Past Releases of Elastic Stack Software | Elastic](https://www.elastic.co/downloads/past-releases#kibana)
```bash ```bash
[root@kibana ~]# wget https://artifacts.elastic.co/downloads/kibana/kibana-8.13.4-linux-x86_64.tar.gz [root@kibana ~]# wget https://artifacts.elastic.co/downloads/kibana/kibana-8.13.4-linux-x86_64.tar.gz
``` ```
### 2. 安装部署 ### 2. 安装部署
```bash ```bash
[root@kibana ~]# tar xf kibana-8.13.4-linux-x86_64.tar.gz -C /usr/local/ [root@kibana ~]# tar xf kibana-8.13.4-linux-x86_64.tar.gz -C /usr/local/
[root@kibana ~]# mv /usr/local/kibana-8.13.4/ /usr/local/kibana [root@kibana ~]# mv /usr/local/kibana-8.13.4/ /usr/local/kibana
[root@kibana ~]# mkdir /usr/local/kibana/config/certs [root@kibana ~]# mkdir /usr/local/kibana/config/certs
``` ```
### 3. 修改配置 ### 3. 修改配置
```bash ```bash
[root@kibana ~]# vim /usr/local/kibana/config/kibana.yml [root@kibana ~]# vim /usr/local/kibana/config/kibana.yml
server.port: 5601 server.port: 5601
server.host: "192.168.159.134" server.host: "192.168.159.134"
server.name: "kibana" server.name: "kibana"
elasticsearch.hosts: ["https://192.168.159.131:9200"] elasticsearch.hosts: ["https://192.168.159.131:9200"]
elasticsearch.username: "kibana" elasticsearch.username: "kibana"
elasticsearch.password: "123456" elasticsearch.password: "123456"
elasticsearch.ssl.certificateAuthorities: [ "/usr/local/kibana/config/certs/elasticsearch-ca.pem" ] elasticsearch.ssl.certificateAuthorities: [ "/usr/local/kibana/config/certs/elasticsearch-ca.pem" ]
i18n.locale: "zh-CN" i18n.locale: "zh-CN"
``` ```
### 4. 获取Elasticsearch 的CA证书 ### 4. 获取Elasticsearch 的CA证书
```bash ```bash
[root@kibana ~]# scp 192.168.159.131:/usr/local/elasticsearch/config/certs/elasticsearch-ca.pem /usr/local/kibana/config/certs/ [root@kibana ~]# scp 192.168.159.131:/usr/local/elasticsearch/config/certs/elasticsearch-ca.pem /usr/local/kibana/config/certs/
``` ```
### 5. 创建运行用户 ### 5. 创建运行用户
```bash ```bash
[root@kibana ~]# useradd kibana [root@kibana ~]# useradd kibana
[root@kibana ~]# echo kibana | passwd --stdin kibana [root@kibana ~]# echo kibana | passwd --stdin kibana
[root@kibana ~]# chown -R kibana:kibana /usr/local/kibana/ [root@kibana ~]# chown -R kibana:kibana /usr/local/kibana/
``` ```
### 6. 启动Kibana ### 6. 启动Kibana
```bash ```bash
[root@kibana ~]# su - kibana [root@kibana ~]# su - kibana
[kibana@kibana ~]$ /usr/local/kibana/bin/kibana [kibana@kibana ~]$ /usr/local/kibana/bin/kibana
``` ```
### 7. 常见故障 ### 7. 常见故障
```bash ```bash
Error: [config validation of [elasticsearch].username]: value of "elastic" is forbidden. This is a superuser account that cannot write to system indices that Kibana needs to function. Use a service account token instead. Learn more: https://www.elastic.co/guide/en/elasticsearch/reference/8.0/service-accounts.html Error: [config validation of [elasticsearch].username]: value of "elastic" is forbidden. This is a superuser account that cannot write to system indices that Kibana needs to function. Use a service account token instead. Learn more: https://www.elastic.co/guide/en/elasticsearch/reference/8.0/service-accounts.html
at ensureValidConfiguration (/usr/local/kibana/node_modules/@kbn/core-config-server-internal/src/ensure_valid_configuration.js:23:11) at ensureValidConfiguration (/usr/local/kibana/node_modules/@kbn/core-config-server-internal/src/ensure_valid_configuration.js:23:11)
``` ```
解决方案: 解决方案:
该版本的kibana在连接es集群中不支持使用elasticsearch中elastic超级管理员账户连接 该版本的kibana在连接es集群中不支持使用elasticsearch中elastic超级管理员账户连接
在es集群中自带的kibana账户设定密码 在es集群中自带的kibana账户设定密码
```bash ```bash
[elasticsearch@elasticsearch1 ~]$ /usr/local/elasticsearch/bin/elasticsearch-reset-password -u kibana -i [elasticsearch@elasticsearch1 ~]$ /usr/local/elasticsearch/bin/elasticsearch-reset-password -u kibana -i
warning: ignoring JAVA_HOME=/usr/local/elasticsearch/jdk; using bundled JDK warning: ignoring JAVA_HOME=/usr/local/elasticsearch/jdk; using bundled JDK
This tool will reset the password of the [kibana] user. This tool will reset the password of the [kibana] user.
You will be prompted to enter the password. You will be prompted to enter the password.
Please confirm that you would like to continue [y/N]y Please confirm that you would like to continue [y/N]y
Enter password for [kibana]: Enter password for [kibana]:
Re-enter password for [kibana]: Re-enter password for [kibana]:
Password for the [kibana] user successfully reset. Password for the [kibana] user successfully reset.
``` ```
扩展: 扩展:
Elasticsearch中创建用户 Elasticsearch中创建用户
```bash ```bash
[elasticsearch@elasticsearch1 ~]$ /usr/local/elasticsearch/bin/elasticsearch-users useradd test_account [elasticsearch@elasticsearch1 ~]$ /usr/local/elasticsearch/bin/elasticsearch-users useradd test_account
``` ```
为用户分配角色 为用户分配角色
```bash ```bash
[elasticsearch@elasticsearch1 ~]$ /usr/local/elasticsearch/bin/elasticsearch-users roles -a superuser test_account [elasticsearch@elasticsearch1 ~]$ /usr/local/elasticsearch/bin/elasticsearch-users roles -a superuser test_account
``` ```
### 8. 浏览器访问 ### 8. 浏览器访问
![](accents\image-202505020020.png) ![](http://182.92.143.66:40072/directlink/img/es/image-202505020020.png)
注意: 注意:
用户名和密码是es集群登录的用户和密码 用户名和密码是es集群登录的用户和密码
![](accents\image-202505020021.png) ![](http://182.92.143.66:40072/directlink/img/es/image-202505020021.png)
![](accents\image-202505020022.png) ![](http://182.92.143.66:40072/directlink/img/es/image-202505020022.png)
## 三:配置使用 ## 三:配置使用
注意此部分的使用在做完《Logstash》中第一节和第二节后在使用 注意此部分的使用在做完《Logstash》中第一节和第二节后在使用
### 1. Logstash采集到数据进行展示 ### 1. Logstash采集到数据进行展示
进入管理界面 进入管理界面
![](accents\image-202505020023.png) ![](http://182.92.143.66:40072/directlink/img/es/image-202505020023.png)
![](accents\image-202505020024.png) ![](http://182.92.143.66:40072/directlink/img/es/image-202505020024.png)
进入索引管理 进入索引管理
![](accents\image-202505020025.png) ![](http://182.92.143.66:40072/directlink/img/es/image-202505020025.png)
进入要管理的索引 进入要管理的索引
![](accents\image-202505020035.png) ![](http://182.92.143.66:40072/directlink/img/es/image-202505020035.png)
展示索引数据 展示索引数据
![](accents\image-202505020036.png) ![](http://182.92.143.66:40072/directlink/img/es/image-202505020036.png)
创建数据视图 创建数据视图
![](accents\image-202505020037.png) ![](http://182.92.143.66:40072/directlink/img/es/image-202505020037.png)
![](accents\image-202505020038.png) ![](http://182.92.143.66:40072/directlink/img/es/image-202505020038.png)
![](accents\image-202505020039.png) ![](http://182.92.143.66:40072/directlink/img/es/image-202505020039.png)
注意: 注意:
- 这里我们就可以看到Logstash采集的数据并以图形的方式展示 - 这里我们就可以看到Logstash采集的数据并以图形的方式展示
- 在图形界面我们可以设置时间范围 - 在图形界面我们可以设置时间范围
- 在图形界面我们可以设置时间自动刷新时间 - 在图形界面我们可以设置时间自动刷新时间