Kibana数据可视化

介绍

Kibana 是一款开源的数据分析和可视化平台,它是 Elastic Stack 成员之一,设计用于和 Elasticsearch 协作。您可以使用 Kibana 对 Elasticsearch 索引中的数据进行搜索、查看、交互操作。您可以很方便的利用图表、表格及地图对数据进行多元化的分析和呈现。

官网:https://www.elastic.co/cn/kibana

安装

1
2
3
4
5
6
7
8
9
10
11
# Create a file called kibana.repo in the /etc/yum.repos.d/ directory for RedHat based distributions
sudo echo "[kibana-7.15.1]
name=Kibana repository for 7.15.1 packages
baseurl=https://artifacts.elastic.co/packages/7.15.1/yum
gpgcheck=1
gpgkey=https://artifacts.elastic.co/GPG-KEY-elasticsearch
enabled=1
autorefresh=1
type=rpm-md" > /etc/yum.repos.d/kibana.repo

sudo yum install kibana
1
2
3
4
5
6
docker network create elastic
docker pull docker.elastic.co/elasticsearch/elasticsearch:7.15.2
docker run --name es01-test --net elastic -p 9200:9200 -p 9300:9300 -e "discovery.type=single-node" docker.elastic.co/elasticsearch/elasticsearch:7.15.2

docker pull docker.elastic.co/kibana/kibana:7.15.1
docker run --name kib01-test --net elastic -p 5601:5601 -e "ELASTICSEARCH_HOSTS=http://119.255.249.177:9200" docker.elastic.co/kibana/kibana:7.15.1
1
2
3
4
5
6
7
8
9
10
11
12
13
14
# 解压
tar -zxvf kibana-7.15.1-linux-x86_64.tar.gz
# 重命名
mv kibana-7.15.1-linux-x86_64 kibana
## 然后在进入kibana目录,找到config文件夹下的kibana.yml进行配置的修改

grep -Ev "^#|^$" kibana.yml
## 输出如下
server.host: "0.0.0.0" #对外暴露服务的地址
elasticsearch.hosts: ["http://192.168.0.8:9200","http://192.168.0.13:9200"] #配置Elasticsearch

sed -i 's#\#server.host: "localhost"#server.host: "0.0.0.0"#' kibana.yml

sed -i 's#\#elasticsearch.hosts: \["http://localhost:9200"\]#elasticsearch.hosts: \["http://192.168.0.8:9200","http://192.168.0.13:9200"\]#' kibana.yml

Metricbeat 仪表盘

现在将Metricbeat的数据展示在Kibana中,首先需要修改我们的MetricBeat配置

1
2
3
4
5
6
7
#修改metricbeat配置
setup.kibana:
host: "192.168.40.133:5601"

#安装仪表盘到Kibana【需要确保Kibana在正常运行,这个过程可能会有些耗时】
./metricbeat setup --dashboards
./metricbeat -e

然后到kibana页面下,找到刚刚安装的仪表盘**[Metricbeat System] Host overview ECS**, 得到如下界面

metricbeat_kibana

Nginx 指标仪表盘

首先打开nginx状态;
然后到kibana页面下,找到仪表盘**[Metricbeat Nginx] Overview**,

Nginx 日志仪表盘

我们可以和刚刚Metricbeat的仪表盘一样,也可以将filebeat收集的日志记录,推送到Kibana中

首先我们需要修改filebeat的 kibana-nginx.yml配置文件

1
2
3
4
5
6
7
8
9
10
filebeat.inputs:
setup.template.settings:
index.number_of_shards: 1
output.elasticsearch:
hosts: ["119.255.249.177:9200"]
filebeat.config.modules:
path: ${path.config}/modules.d/*.yml
reload.enabled: false
setup.kibana:
host: "119.254.169.244:5601"

然后按照仪表盘

1
./filebeat -c kibana-nginx.yml setup

安装成功显示如下:
kibana-filebeat

然后我们启动filebeat即可

1
./filebeat -e -c kibana-nginx.yml

kibana-nginxlog

自定义图标

Visualize 里设置,然后可以在Dashboard里导入。

开发者工具

kibana-devtool