Skip to content

Commit 4aa7d43

Browse files
committed
添加 elk 相关配置
1 parent bb0cd36 commit 4aa7d43

5 files changed

Lines changed: 19 additions & 4 deletions

File tree

codes/javatool/src/main/resources/logback.xml

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,15 +32,16 @@
3232
<appender name="ELK-UDP" class="net.logstash.logback.appender.LogstashSocketAppender">
3333
<host>192.168.28.32</host>
3434
<port>9250</port>
35-
<customFields>{"appname":"myWebservice"}</customFields>
3635
</appender>
3736
<appender name="ELK-TCP" class="net.logstash.logback.appender.LogstashTcpSocketAppender">
3837
<!--
3938
destination 是 logstash 服务的 host:port,
4039
相当于和 logstash 建立了管道,将日志数据定向传输到 logstash
4140
-->
4241
<destination>192.168.28.32:9251</destination>
43-
<encoder charset="UTF-8" class="net.logstash.logback.encoder.LogstashEncoder"/>
42+
<encoder charset="UTF-8" class="net.logstash.logback.encoder.LogstashEncoder">
43+
<customFields>{"appname":"javatool"}</customFields>
44+
</encoder>
4445
</appender>
4546

4647
<!-- RollingFileAppender end -->
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
input {
2+
file {
3+
path => ["/var/log/nginx/access.log"]
4+
type => "nginx-access-log"
5+
start_position => "beginning"
6+
}
7+
}
8+
9+
output {
10+
if [type] == "nginx-access-log" {
11+
elasticsearch {
12+
hosts => ["localhost:9200"]
13+
index => "nginx-access-log"
14+
}
15+
}
16+
}
File renamed without changes.

settings/logstash/logstash-input-tcp.conf renamed to settings/elastic/logstash/logstash-input-tcp.conf

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,6 @@ input {
33
port => 9251
44
codec => json_lines
55
mode => server
6-
host => 127.0.0.1
7-
tags => ["tags"]
86
}
97
}
108
output {
File renamed without changes.

0 commit comments

Comments
 (0)