1.安装及配置Kibana

cd /usr/local/src
yum -y install kibana-5.4.0-x86_64.rpm
grep "^[a-Z]" /etc/kibana/kibana.yml
server.port: 5601
server.host: "10.0.0.22"
elasticsearch.url: "http://10.0.0.22:9200" systemctl enable kibana
systemctl start kibana
# 浏览器访问10.0.0.22:5601,通过http://10.0.0.22:5601/status来查看是否正常

2.通过配置logstash文件收集message日志

在Kibana上展示上一节收集的日志信息,添加索引

使用logstash配置文件收集messages日志

vim /etc/logstash/conf.d/system.conf
input {
file {
path => "/var/log/messages"
type => "systemlog"
start_position => "beginning"
stat_interval => "2"
}
} output {
elasticsearch {
hosts => ["10.0.0.22:9200"]
index => "logstash-systemlog-%{+YYYY.MM.dd}"
}
}
path => "/var/log/messages":要收集的文件路径
start_position => "beginning":从什么位置开始读取文件数据,默认是结束位置,会以类似 tail -F 的形式运行.
如果你是要导入原有数据,把这个设定改成"beginning",logstash 进程就从头开始读取,类似 less +F 的形式运行.
stat_interval => "2":每隔多久检查一次
/usr/share/logstash/bin/logstash -f /etc/logstash/conf.d/system.conf -t # 检测配置文件是否有语法错误
ll /var/log/messages # logstash是普通用户,想要对系统日志有读权限,就得改文件权限
chmod 644 /var/log/messages
systemctl restart logstash

在管理界面查看是否有相应的索引

添加到Kibana中展示,创建索引

3.使用一个配置文件收集多个日志(这个配置文件是后来改过的)

cat /etc/logstash/conf.d/colectTwo.conf
input {
file {
path => "/var/log/nginx/access.log"
type => "nginx-access"
start_position => "beginning"
stat_interval => "2"
}
file {
path => "/var/log/nginx/error.log"
type => "nginx-error"
start_position => "beginning"
stat_interval => "2"
}
file {
path => "/var/log/mysql.log"
type => "mysql-log"
start_position => "beginning"
stat_interval => "2"
}
} output {
if [type] == "nginx-access" {
elasticsearch {
hosts => ["10.0.0.22:9200"]
index => "logstash-nginx-access-%{+YYYY.MM.dd}"
}
} if [type] == "nginx-error" {
elasticsearch {
hosts => ["10.0.0.22:9200"]
index => "logstash-nginx-error-%{+YYYY.MM.dd}"
}
}
if [type] == "mysql-log" {
elasticsearch {
hosts => ["10.0.0.22:9200"]
index => "logstash-mysql-log-%{+YYYY.MM.dd}"
}
}
}
配置文件检测语法是否正常:
/usr/share/logstash/bin/logstash -f /etc/logstash/conf.d/colectTwo.conf -t
systemctl restart logstash
echo qweqweqweasdqwedqwe > /var/log/mysql.log
chmod 666 /var/log/mysql.log
usermod -G adm logstash

通过head插件查看

Kibana创建索引[logstash-nginx-access-]YYYY.MM.DD:

Kibana部署及message日志收集:http://blog.51cto.com/jinlong/2055042

最新文章

  1. 【单页应用巨坑之History】细数History带给单页应用的噩梦
  2. GitHub 上 57 款最流行的开源深度学习项目
  3. String与InputStream互转的几种方法
  4. 《Visual C++并行编程实战》译者序
  5. 《JAVA NIO》第二章缓冲区
  6. SqlServer Split函数
  7. Android 实现Path2.0中绚丽的的旋转菜单
  8. 部分常用Express方法详解
  9. decimall类型数据
  10. 基于curl 的zabbix API调用
  11. Vnstat: 简单实用的网络流量统计工具
  12. 坑爹JDK8,可怜的XP
  13. OpenStack_Swift源代码分析——Ring基本原理及一致性Hash算法
  14. ORACLE总结系列1--network文件夹里的admin的三个文件信息
  15. Activity间传递数据
  16. k-近邻算法-优化约会网站的配对效果
  17. 生产者-消费者(wait-notify实现)
  18. 排序算法<No.1> 【计数排序】
  19. nodepad++ 正则 替换
  20. flex布局知识点(阮一峰博客)

热门文章

  1. tomcat性能优化 - 网络抄录
  2. 前台解析json的方法
  3. Bootstrap历练实例:弹出提示信息的样式按钮
  4. ios设备屏幕尺寸与分辨率
  5. 表单input中提示文字value随鼠标焦点移进移出而显示或隐藏的
  6. (29)zabbix执行远程命令
  7. 【php】 php的注释问题,单行注释和多行注释与php结束符的关系
  8. Python多版本共存安装
  9. 树形 dp
  10. 浅谈 HTTP 协议