集成elk收集日志
This commit is contained in:
21
document/elk/elk.md
Normal file
21
document/elk/elk.md
Normal file
@@ -0,0 +1,21 @@
|
||||
#windows下的elk环境搭建
|
||||
|
||||
##下载
|
||||
下载页面:https://www.elastic.co/downloads/past-releases
|
||||
ElasticSearch:https://www.elastic.co/downloads/past-releases/elasticsearch-2-4-6
|
||||
Logstash:https://www.elastic.co/downloads/past-releases/logstash-2-4-0
|
||||
Kibana:https://www.elastic.co/downloads/past-releases/kibana-4-6-0
|
||||
|
||||
##安装
|
||||
下载zip包并进行解压
|
||||
|
||||
##运行
|
||||
|
||||
###logstash配置运行
|
||||
添加logstash配置文件:logstash-springboot.conf
|
||||
安装logstash-codec-json_lines插件:plugin install logstash-codec-json_lines
|
||||
运行logstash命令:logstash -f logstash-springboot.conf
|
||||
|
||||
##SpringBoot整合logstash
|
||||
引入依赖包:https://github.com/logstash/logstash-logback-encoder
|
||||
添加配置文件:logback-spring.xml
|
||||
14
document/elk/logback-spring.xml
Normal file
14
document/elk/logback-spring.xml
Normal file
@@ -0,0 +1,14 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!DOCTYPE configuration>
|
||||
<configuration>
|
||||
<include resource="org/springframework/boot/logging/logback/base.xml"/>
|
||||
<appender name="LOGSTASH" class="net.logstash.logback.appender.LogstashTcpSocketAppender">
|
||||
<destination>localhost:4560</destination>
|
||||
<encoder charset="UTF-8" class="net.logstash.logback.encoder.LogstashEncoder" />
|
||||
</appender>
|
||||
<root level="INFO">
|
||||
<appender-ref ref="LOGSTASH" />
|
||||
<appender-ref ref="CONSOLE" />
|
||||
</root>
|
||||
|
||||
</configuration>
|
||||
10
document/elk/logstash-springboot.conf
Normal file
10
document/elk/logstash-springboot.conf
Normal file
@@ -0,0 +1,10 @@
|
||||
input {
|
||||
tcp {
|
||||
port => 4560
|
||||
codec => json_lines
|
||||
}
|
||||
}
|
||||
output{
|
||||
elasticsearch { hosts => ["localhost:9200"] }
|
||||
stdout { codec => rubydebug }
|
||||
}
|
||||
Reference in New Issue
Block a user