服务主体:html
(1)Logstash:用来搜集日志node
(2)Elasticsearch:存储各种日志linux
(3)Kibana:web化接口用做查寻和可视化日志git
(4)sentinl插件:配置触发条件和触发事件github
备注:在复杂系统中,Logstash还能够细分为3部分,分别为logstash shipper(做为logstash agent,用于监控并过滤收集日志)、Redis(缓存)、logstash indexer(做为 logstash server,将日志收集后交给全文搜索服务ElasticSearch);在简单系统中,直接部署Logstash便可,本文即采用这种方式;web
ELK主体下载地址:https://www.elastic.co/cn/downloadsapi
Kibana插件sentinl下载地址:https://github.com/sirensolutions/sentinl/releases/
缓存
备注:为了确保兼容性,三大主体及相关插件的版本号尽可能保持一致,本文均采用6.2.4版本安全
参考配置文件连接:elasticsearch.yml
服务器
配置完后直接启动该服务便可
备注:elasticsearch没法以root身份运行!!!启动后能够经过web访问http://192.168.3.97:9200/进行测试,会反馈一个JSON字符串以下:
另外,安装elasticSearch 6.2.4 head插件
参考文档连接:https://blog.csdn.net/zoubf/article/details/79007908input { #输入源
file { #从文件输入(还有不少)
path => "/home/log/log4test/*.log" #文件路径
start_position => "beginning" #检索位置(从头)
}
}
output {
elasticsearch { #输出目的
action => "index" #关键字,以索引的方式
hosts => ["192.168.3.97:9200"] #ES服务IP和端口
index => "hello.%{+YYYY.MM.dd}" #索引命名
}
}
参考配置文件连接:logstash.conf
安装sentinl插件
推荐采用在线安装方式:经过kibana-6.2.4-linux-x86_64/bin/kibana-plugin install https://github.com/sirensolutions/sentinl/releases/download/tag-6.2.3-3/sentinl-v6.2.4.zip
s备注:上述连接中tag-XXX项经过所需下载的相关版本号去https://github.com/sirensolutions/sentinl/releases/自行核对
# Kibana is served by a back end server. This setting specifies the port to use. #该服务端口设置,默认为5601
server.port: 5601
# To allow connections from remote users, set this parameter to a non-loopback address. #该服务IP设置,默认为本机IP
server.host: "192.168.3.97"
# The URL of the Elasticsearch instance to use for all your queries. #ES服务IP和端口配置
elasticsearch.url: "http://192.168.3.97:9200"
# Kibana uses an index in Elasticsearch to store saved searches, visualizations and
# dashboards. Kibana creates a new index if the index doesn't already exist.
kibana.index: ".kibana" #该服务自身的日志文件索引号
sentinl: #sentinl配置
settings:
email:
active: true
user: tebonamdev@tebon.com.cn #发件邮箱用户名
password: ******** #发件邮箱密码
host: mail.tebon.com.cn #发件邮箱服务器
ssl: false #安全证书
timeout: 10000 #邮箱访问超时设置
report:
active: true
executable_path: '/usr/bin/chromium' # path to Chrome v59+ or Chromium v59+
配置完后直接启动该服务便可,可经过web访问http://192.168.3.97:5601/
参考配置文件连接:kibana.yml
备注:sentinl 5.×版本和6.×版本官网推荐的最小配置不一样,具体可参考官网http://sentinl.readthedocs.io/en/latest/Config-Example/#sentinl-configuration-yaml
另外,要使用sentinl还须要配置虚拟机本地/etc/mail.rc:
set from=tebonamdev@tebon.com.cn #发件邮箱用户名
set smtp=mail.tebon.com.cn #发件邮箱服务器
set smtp-auth-user=tebonamdev@tebon.com.cn #发件邮箱用户名
set smtp-auth-password=******** #发件邮箱密码
set smtp-auth=login
参考配置文件连接:mail.rc
备注:sentinl在使用过程当中,告警触发正常,可是邮件发送超时,建议安装官网推荐的emailjs,具体参考:https://github.com/eleith/emailjs
另外,初次配置进行功能实现时,最好关闭ssl,不然可能出现邮件发送超时等问题,涉及域调试起来比较麻烦!!!