kibana日志收集
一、Kibana安装
Kibana 是为 Elasticsearch 设计的开源分析和可视化平台。你可以使用 Kibana 来搜索,查看存储在 Elasticsearch 索引中的数据并与之交互。你可以很容易实现高级的数据分析和可视化,以图表的形式展现出来。
kiabana下载地址:https://artifacts.elastic.co/downloads/kibana/kibana-6.0.0-x86_64.rpm
[root@linux-node1 ~]# wget https://artifacts.elastic.co/downloads/kibana/kibana-6.0.0-x86_64.rpm
[root@linux-node1 ~]# yum install -y kibana-6.0.0-x86_64.rpm
[root@linux-node1 ~]# vim /etc/kibana/kibana.yml
[root@linux-node1 ~]# grep "^[a-Z]" /etc/kibana/kibana.yml
server.port: 5601 #监听端口
server.host: "192.168.56.11" #监听IP地址,建议内网ip
elasticsearch.url: "http://192.168.56.11:9200" #elasticsearch连接kibana的URL,也可以填写192.168.56.12,因为它们是一个集群
[root@linux-node1 ~]# systemctl enable kibana
Created symlink from /etc/systemd/system/multi-user.target.wants/kibana.service to /etc/systemd/system/kibana.service.
[root@linux-node1 ~]# systemctl start kibana
监听端口为:5601
[root@linux-node1 ~]# ss -tnl
State Recv-Q Send-Q Local Address:Port Peer Address:Port
LISTEN 0 128 *:9100 *:*
LISTEN 0 128 *:22 *:*
LISTEN 0 100 127.0.0.1:25 *:*
LISTEN 0 128 192.168.56.11:5601 *:*
LISTEN 0 128 ::ffff:192.168.56.11:9200 :::*
LISTEN 0 128 ::ffff:192.168.56.11:9300 :::*
LISTEN 0 128 :::22 :::*
LISTEN 0 100 ::1:25 :::*
LISTEN 0 80 :::3306 :::*
浏览器访问192.168.56.11:5601,如图:
可以通过http://192.168.56.11:5601/status 来查看看是否正常,如果不正常,是无法进入到上图界面
二、通过配置logstash文件收集message日志
1、Kibana展示上一节的日志
在Kibana上展示上一节收集的日志信息,添加索引,如图:
点击“discover”查看收集的信息,如图:
2、使用logstash配置文件收集messages日志
编辑logstash的配置文件:
[root@linux-node1 ~]# vim /etc/logstash/conf.d/system.conf
input {file {path => "/var/log/messages" #日志路径type => "systemlog" #类型start_position => "beginning" #logstash 从什么位置开始读取文件数据,默认是结束位置,也就是说 logstash 进程会以类似 tail -F 的形式运行。如果你是要导入原有数据,把这个设定改成"beginning",logstash 进程就从头开始读取,类似 less +F 的形式运行。stat_interval => "2" #logstash 每隔多久检查一次被监听文件状态(是否有更新) ,默认是 1 秒。}
}output {elasticsearch {hosts => ["192.168.56.11:9200"] #指定hostsindex => "logstash-systemlog-%{+YYYY.MM.dd}" #索引名称}}
[root@linux-node1 ~]# /usr/share/logstash/bin/logstash -f /etc/logstash/conf.d/system.conf -t #检测配置文件是否有语法错误
OpenJDK 64-Bit Server VM warning: If the number of processors is expected to increase from one, then you should configure the number of parallel GC threads appropriately using -XX:ParallelGCThreads=N
WARNING: Could not find logstash.yml which is typically located in $LS_HOME/config or /etc/logstash. You can specify the path using --path.settings. Continuing using the defaults
Could not find log4j2 configuration at path /usr/share/logstash/config/log4j2.properties. Using default config which logs errors to the console
Configuration OK
[root@linux-node1 ~]# ll /var/log/messages
-rw-------. 1 root root 791209 12月 27 11:43 /var/log/messages
#这里可以看到该日志文件是600权限,而elasticsearch是运行在elasticsearch用户下,这样elasticsearch是无法收集日志的。所以这里需要更改日志的权限,否则会报权限拒绝的错误。在日志中查看/var/log/logstash/logstash-plain.log 是否有错误
。
[root@linux-node1 ~]# chmod 644 /var/log/messages
[root@linux-node1 ~]# systemctl restart logstash
在管理界面查看是否有相应的索引(logstash-systemlog-2017.12.27),如图:
添加到Kibana中展示,创建索引:
查看日志
三、使用一个配置文件收集多个日志
修改logstash的配置文件,这里增加收集数据库mariadb的日志:
[root@linux-node1 ~]# vim /etc/logstash/conf.d/system.conf
input {file {path => "/var/log/messages"type => "systemlog"start_position => "beginning"stat_interval => "2"}file {path => "/var/log/mariadb/mariadb.log"type => "mariadblog"start_position => "beginning"stat_interval => "2"}
}output {if [type] == "systemlog" { #使用if来判断类型,并输出到elasticsearch和file,展示一个out可以作多样输出elasticsearch {hosts => ["192.168.56.11:9200"]index => "logstash-systemlog-%{+YYYY.MM.dd}"}file {path => "/tmp/logstash-systemlog-%{+YYYY.MM.dd}"}}if [type] == "mariadblog" {elasticsearch {hosts => ["192.168.56.11:9200"]index => "logstash-mariadblog-%{+YYYY.MM.dd}"}file {path => "/tmp/logstash-mariadblog-%{+YYYY.MM.dd}"}}}
配置文件检测语法是否正常:
[root@linux-node1 ~]# /usr/share/logstash/bin/logstash -f /etc/logstash/conf.d/system.conf -t
OpenJDK 64-Bit Server VM warning: If the number of processors is expected to increase from one, then you should configure the number of parallel GC threads appropriately using -XX:ParallelGCThreads=N
WARNING: Could not find logstash.yml which is typically located in $LS_HOME/config or /etc/logstash. You can specify the path using --path.settings. Continuing using the defaults
Could not find log4j2 configuration at path /usr/share/logstash/config/log4j2.properties. Using default config which logs errors to the console
Configuration OK
重启logstash:
[root@linux-node1 ~]# systemctl restart logstash
修改mariadb的日志权限:
[root@linux-node1 ~]# ll /var/log/mariadb/ -d
drwxr-x--- 2 mysql mysql 24 12月 4 17:43 /var/log/mariadb/
[root@linux-node1 ~]# chmod 755 /var/log/mariadb/
[root@linux-node1 ~]# ll /var/log/mariadb/mariadb.log
-rw-r----- 1 mysql mysql 114993 12月 27 14:23 /var/log/mariadb/mariadb.log
[root@linux-node1 ~]# chmod 644 /var/log/mariadb/mariadb.log
通过head插件查看:
查看是否在/tmp下收集到了日志数据
[root@linux-node1 ~]# ll /tmp/logstash-*
-rw-r--r-- 1 logstash logstash 288449 12月 27 14:27 /tmp/logstash-mariadblog-2017.12.27
-rw-r--r-- 1 logstash logstash 53385 12月 27 14:28 /tmp/logstash-systemlog-2017.12.27
Kibana创建索引:
kibana日志收集相关推荐
- EFK(Elasticsearch+Filebeat+Kibana)日志收集系统
EFK简介 Elasticsearch 是一个实时的.分布式的可扩展的搜索引擎,允许进行全文.结构化搜索,它通常用于索引和搜索大量日志数据,也可用于搜索许多不同类型的文档. Beats 是数据采集的得 ...
- 基于ELK打造强大的日志收集分析系统(springboot2+logback+logstash+elasticsearch+kibana)
前言 上一代的日志分析系统springboot+log4j+flume+kafka仿佛还是昨天,现在已经流行起了新一代的springboot2+logback+logstash+elasticsear ...
- Kubernetes 日志收集的原理,看这一篇就够了
准备 关于容器日志 Docker 的日志分为两类,一类是 Docker 引擎日志:另一类是容器日志.引擎日志一般都交给了系统日志,不同的操作系统会放在不同的位置. 本文主要介绍容器日志,容器日志可以理 ...
- 看不到日志_Kubernetes中常用的日志收集方案
在kubernetes中对日志的处理方式叫做cluster-level-logging,即这个日志处理系统跟容器,Pod,Node的生命周期无关,也就是无论是容器挂了,Pod被删除了还是Node宕机了 ...
- asp.Net Core免费开源分布式异常日志收集框架Exceptionless安装配置以及简单使用图文教程...
最近在学习张善友老师的NanoFabric 框架的时了解到Exceptionless : https://exceptionless.com/ !因此学习了一下这个开源框架!下面对Exceptionl ...
- filebeat 收集json格式_集群日志收集架构ELK
欢迎关注头条号:老顾聊技术 精品原创技术分享,知识的组装工 前言 前几篇我们介绍了项目中如何使用logback组件记录系统的日志情况:现在我们的系统都是分布式的,集群化的,那就代表着我们的应用会分布在 ...
- SpringCloud实践分享-日志收集Kafka-ELK
2019独角兽企业重金招聘Python工程师标准>>> 微服务应用在容器化后,日志的查询就会变成困难的问题,虽说有portainer这类的容器管理工具,能够方便的查询每个容器中的日志 ...
- 企业级日志收集系统——ELKstack
ELKstack简介: ELKstack是Elasticsearch.Logstash.Kibana三个开源软件的组合而成,形成一款强大的实时日志收集展示系统. 各组件作用如下: Logstash:日 ...
- 转: 基于elk 实现nginx日志收集与数据分析
原文链接:https://www.cnblogs.com/wenchengxiaopenyou/p/9034213.html 一.背景 前端web服务器为nginx,采用filebeat + logs ...
- 你居然还去服务器上捞日志,搭个日志收集系统难道不香么!
摘要 ELK日志收集系统进阶使用,本文主要讲解如何打造一个线上环境真实可用的日志收集系统.有了它,你就可以和去服务器上捞日志说再见了! ELK环境安装 ELK是指Elasticsearch.Kiban ...
最新文章
- vs2005 打sp1补丁失败的解决办法
- Mysql元数据分析
- 解决pycharm创建github工程但push失败的问题
- 同步异步单线程多线程初级理解
- 2018CCPC吉林赛区(重现赛)补题部分——F线段树待补
- 经典面试题(13):如何理解和应用JavaScript闭包?
- linux 下测速时间分析
- 甘肃暴雨强度公式_我国若干城暴雨强度公式列表.doc
- 常用测试工具-----XCAP
- 快速去除PDF打开密码和限制
- 2017-2018 ACM-ICPC, Asia Daejeon Regional Contest 补题
- esp8266 nvs应用
- pion实现录制WebRTC流
- NOI的1.9.8白细胞计数
- “如果有借鉴意义的话” —— 从上帝视角复盘Offer选择
- MethodType用法和setattr区别
- mac 浏览器解决跨域问题
- 全球开源数据库领域之翘楚相聚帝都—–ACMUG 2016 MySQL年会
- 2020-09-10 MYSQL按时间段分组查询当天,每小时,15分钟数据分组
- 视频点播RTMP推流直播流媒体服务二次开发集成接口
热门文章
- 怎么卸载apowerrec_如何卸载win10自带的游戏中心
- 调度系统核心算法第一篇-交通管制
- 修改dataV轮播表背景图
- JADE学习笔记1:JADE简介与配置
- XISE-WBMS管理V30.0最新无后门过狗过WAF版
- win10虚拟打印服务器,win10虚拟打印机驱动怎么安装_win10系统安装虚拟打印机驱动教程...
- 【业余无线电BI1FKP】宝峰UV9R-Plus写频、自制写频线
- matlab符号函数作图,matlab制图—符号函数(显函数、隐函数和参数方程)画图
- 9小时速返地球!刚刚,神舟十三号返回舱平安降落,三位航天员“感觉良好”...
- opencms9.0安装