換了個運行環境,從新搭建一套公司本地內部的ELK,以前也搭過(可訪問:https://yanganlin.com/31.html),最近作什麼事情都想用Docker,此次也用Docker,還算順利,沒掉什麼坑裏,上次搭建,也用用的6.2+的版本,這都過了一年,Elk這三個產品,都已經上7了,用docker搭建的仍是用6.2.4,穩定不落伍就好
html
安裝node
docker run \ -d \ --name elasticsearch \ -p 9200:9200 \ -p 9300:9300 \ -e "discovery.type=single-node" \ docker.elastic.co/elasticsearch/elasticsearch:6.2.4
訪問http://localhost:9200
spring
安裝docker
docker run \ -d \ -u 0 \ --name kibana \ -p 5601:5601\ docker.elastic.co/kibana/kibana:6.2.4
進入到容器內部:docker exec -it kibana /bin/bash
找到kibana的配置文件:/usr/share/kibana/config/ kibana.yml
重啓容器:doccker restart kibana
shell
修改配置文件,由於要繞過x-pack的安全檢查json
elasticsearch.url: http://localhost:9200 xpack.monitoring.ui.container.elasticsearch.enabled: false
安裝安全
docker run \ -d \ -u 0 \ --name logstash \ -p 5044:5044\ docker.elastic.co/logstash/logstash:6.2.4
進入容器:docker exec -it logstash /bin/bash
springboot
找到文件:/usr/share/logstash/pipeline
ruby
修改配置文件logstash.conf
bash
input { tcp { port => 5044 codec => json_lines } } output{ elasticsearch { hosts => ["localhost:9200"] action => "index" index => "%{[appname]}" } stdout { codec => rubydebug } }
重啓容器:doccker restart logstash
logback.xml
<appender name="LOGSTASH" class="net.logstash.logback.appender.LogstashTcpSocketAppender"> <destination>localhost:5044</destination> <encoder charset="UTF-8" class="net.logstash.logback.encoder.LogstashEncoder"> <customFields>{"appname":"eureka-server"}</customFields> </encoder> </appender> <root level="INFO"> <appender-ref ref="LOGSTASH"/> </root>
pom.xml
<dependency> <groupId>net.logstash.logback</groupId> <artifactId>logstash-logback-encoder</artifactId> <version>4.9</version> </dependency>