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