ELK日志分析平台(二):kibana数据可视化
目录实验前准备:kibana数据可视化使用metricbeat设置监测使用metricbeat监测文件采集(使用filebeat)实验前准备:server1:cd elasticsearch-head-master/vim _site/app.js4388行:this.base_uri = this.config.base_uri || this.prefs.get("app-base_uri")
目录
实验前准备:
server1:
cd elasticsearch-head-master/ vim _site/app.js 4388行:this.base_uri = this.config.base_uri || this.prefs.get("app-base_uri") || "http://172.25.70.1:9200"; ##指向es主机的地址 cnpm run start & systemctl start elasticsearch.service #集群里的三台机子(server1、2、3)都要启动【因为之前没有设置开机自起】
网页:172.25.70.1:9100 ##可以连上es
kibana数据可视化
server4:
安装rpm包
rpm -ivh kibana-7.6.1-x86_64.rpm
编辑主配置文件:/etc/kibana/kibana.yml
cd /etc/kibana/
vim kibana.yml
7 server.host: "172.25.70.4"
28 elasticsearch.hosts: ["http://172.25.70.1:9200"]
37 kibana.index: ".kibana"
115 i18n.locale: "zh-CN"
systemctl restart kibana
等待端口启动:5601
netstat -antlp |grep 5601
网页:172.25.70.4:5601
使用样例数据--点击web logs
点击管理--索引模式--创建索引模式
点击可视化--创建可视化--指标
server4:
systemctl start httpd
curl localhost
真机中:压力测试
ab -c1 -n500 http://172.25.70.4/index.html
#在网页上就可以看到信息数据了
在es上可以看到生成新的es和新的索引
kibana:点击保存
点击可视化--创建新可视化--垂直条形图
server1:
yum install -y httpd-tools
ab -c1 -n200 http://172.25.70.4/index.html
server2:
yum install -y httpd-tools
ab -c1 -n300 http://172.25.70.4/index.html
kibana:点击刷新可以看到刚才的数据,依次排开
点击保存
##可以创建更多可视化
把可视化的指标放到仪表板里
点击仪表板--创建仪表板--点击添加-(把刚才保存的两个可视化图放到一起),时时刷新
使用metricbeat设置监测
【需要认证】
server1:
先创建证书
cd /usr/share/elasticsearch/bin/
ls
cd ..
bin/elasticsearch-certutil ca 【直接回车】
ls
bin/elasticsearch-certutil cert --ca elastic-stack-ca.p12
ls
cp elastic-certificates.p12 /etc/elasticsearch/
cd /etc/elasticsearch/
ll
chown elasticsearch elastic-certificates.p12 #设置权限让elasticsearch可以读
ll
vim /etc/elasticsearch/elasticsearch.yml #修改配置文件
#在最后添加
xpack.security.enabled: true #打开安全设置
xpack.security.transport.ssl.enabled: true
xpack.security.transport.ssl.verification_mode: certificate #证书校验模式
xpack.security.transport.ssl.keystore.path: /etc/elasticsearch/elastic-certificates.p12
xpack.security.transport.ssl.truststore.path: /etc/elasticsearch/elastic-certificates.p12
ls
systemctl restart elasticsearch.service
把证书拷贝到server2、3
server2:(server2、3跟server1同理)
cd /etc/elasticsearch/
ll
vim elasticsearch.yml
#在最后添加
xpack.security.enabled: true #打开安全设置
xpack.security.transport.ssl.enabled: true
xpack.security.transport.ssl.verification_mode: certificate #证书校验模式
xpack.security.transport.ssl.keystore.path: /etc/elasticsearch/elastic-certificates.p12
xpack.security.transport.ssl.truststore.path: /etc/elasticsearch/elastic-certificates.p12
chown elasticsearch elastic-certificates.p12
ll
systemctl restart elasticsearch.service
server3同理
网页中:head这个时候链接不上去了,链接的话需要认证
需要集群全部开启【start elasticsearch.service】
server1中:
执行设置密码
cd bin/
ls
./elasticsearch-setup-passwords interactive #设置交互式密码(一个用户输入两遍密码)
网页上:kibana也链接不上去
server4:
cd /etc/kibana/
vim kibana.yml
46 elasticsearch.username: "kibana"
47 elasticsearch.password: "westos"
systemctl restart kibana
重启完成后访问172.25.70.4:5601没有问题。
有用户名认证:用户:elastic,密码:westos--登陆
再次点击监测就不会报错
此时head还无法链接
可以用容器的方法
真机中:(普通用户)
podman ps
podman ps -a
podman start cerebro
网页: 172.25.70.250:9000-->会弹出认证
输入http://172.25.70.1:9200--连接
输入用:elastic,密码:westos--登陆
head链接es需要加入参数
server4:
cd /etc/logstash/conf.d
vim grok.conf
#添加:
21行:user => "elastic"
22行:password => "westos"
logstash -f /etc/logstash/conf.d/grok.conf
server1中:
vim /etc/elasticsearch/elasticsearch.yml
第66行添加: http.cors.allow-headers: Authorization,X-Requested-With,
Content-Length,Content-Type
systemctl restart elasticsearch.service
网页:http://172.25.0.13:9100/?auth_user=elastic&auth_password=westos #就可以直接连接
使用metricbeat监测
网页登陆kibana
用户:elastic,密码:westos--登陆
点击--server1(使用metricbeat监测)--(把localhost改为172.25.70.1)【#填写专门负责监测的es集群,不是之前搭建的123】
点击下一步(跟着这里的步骤做)
server1中:
cd
rpm -ivh metricbeat-7.6.1-x86_64.rpm
cd /etc/metricbeat/modules.d/
ls
metricbeat modules enable elasticsearch-xpack
#作用是把elasticsearch-xpack的后缀.disabled去掉
vim elasticsearch-xpack.yml #修改插件
17 username: "elastic"
18 password: "westos"
cd ..
ls
vim metricbeat.yml #修改主配置文件
94 hosts: ["172.25.70.1:9200"] #把数据汇集到es监测集群里所以填监测集群的地址
101 username: "elastic"
102 password: "westos"
systemctl start metricbeat.service #启动服务
网页上会自动刷新--提示迁移成功
点击监测--使用内部监测--点击节点--可以看到server1已经ok了
server2、3同理
scp metricbeat-7.6.1-x86_64.rpm server2:
scp metricbeat-7.6.1-x86_64.rpm server3:
server2、3同理
cd
rpm -ivh metricbeat-7.6.1-x86_64.rpm
cd /etc/metricbeat/modules.d/
ls
metricbeat modules enable elasticsearch-xpack #作用是把elasticsearch-xpack的后缀.disabled去掉
vim elasticsearch-xpack.yml #修改插件
17 username: "elastic"
18 password: "westos"
cd ..
ls
vim metricbeat.yml #修改主配置文件
94 hosts: ["172.25.70.1:9200"] #把数据汇集到es监测集群里所以填监测集群的地址
101 username: "elastic"
102 password: "westos"
systemctl start metricbeat.service #启动服务
网页上:三台节点都ok了--点击禁用内部采集,可以看到所有节点都使用:metricbeat--退出设置模式
点击概览
文件采集(使用filebeat)
网页上点击节点(节点上所有的es日志也汇集过来)
日志的展示是通过filebeat来展示的
在server1节点上安装filebeat
server1:
rpm -ivh filebeat-7.6.1-x86_64.rpm
cd /etc/filebeat/
ls
cd modules.d/
filebeat modules enable elasticsearch
ls
vim elasticsearch.yml
#跟着filebeat官方文件添加
cd ..
ls
vim filebeat.yml
150 hosts: ["172.25.70.1:9200"]
157 username: "elastic"
158 password: "westos"
systemctl start filebeat.service #启动之后可以拿到server1的日志了
server2、3同理
网页:
点击logs-这个界面可以获得所以节点的日志,可以通过查询匹配,查询日志条目
更多推荐
所有评论(0)