I have nothing to do. When I used es
it before, I saw elk
this thing and didn't know what it was. Later, I found out that it was a thing that collects logs in a unified way. I just had this requirement recently, so I will study it. At present, I only built a simple The single-point project, almost the architecture diagram is like this. Of course it is also possible to remove kafka
this layer.
Because I was studying before log4j2
, and then saw the kafka
accessories inside, I wanted to log4j2
send it directly to kafka
it by the way.
So roughly the following architecture diagram
Of course, it is also possible to app
connect directly Logstash
, but if it is distributed on different machines, you need to configure multiple LogStash
. Of course, it is also possible to have a high level of proficiency.
The version of my accessories is a little different, it's in the windows
environment.
Accessories | Version |
---|---|
log4j2 | 2.x.x |
kafka | 0.10.2.0 |
Logstash | 6.1.3 |
ElasticSearch | 5.4.1 |
Kibana | 5.4.2 |
configuration file
log4j2.xml
<Appenders>
<Kafka name="kafka" topic="log-test">
<PatternLayout>
<pattern>%d{yyyy-MM-dd HH:mm:ss} [%t] %-5level %logger{36} %L - %msg%n</pattern>
</PatternLayout>
<Property name="bootstrap.servers">localhost:9092</Property>
</Kafka>
</Appenders>
logstash.conf
into logstash
the corresponding config
directory
input {
kafka {
bootstrap_servers => ["127.0.0.1:9092"]
group_id => "logstash1"
client_id => "logstash1:::one"
auto_offset_reset => "earliest"
topics => ["log-test"]
}
}
output {
stdout {
codec => rubydebug { }
}
elasticsearch {
hosts => "127.0.0.1"
index => "log-%{+YYYY.MM.dd}"
}
}
Other plugin configurations are default configurations
The construction of ELK clusters has become overwhelming on the Internet.
start command
## kafka.bat
cd /d G:\kafka\kafka
.\bin\windows\kafka-server-start.bat .\config\server.properties
## es.bat
cd /d G:\elk\elasticsearch-5.4.1
.\bin\elasticsearch.bat
## logstash.bat
cd /d G:\elk\logstash-6.1.2\bin
logstash -f ../config/logstash.conf
## kibana.bat
cd /d G:\elk\kibana-5.4.2-windows-x86
./bin/kibana.bat