docker pull docker.elastic.co/elasticsearch/elasticsearch:7.16.2 docker pull docker.elastic.co/logstash/logstash:7.16.2 docker pull docker.elastic.co/kibana/kibana:7.16.2 # Linux 特有配置 sysctl -w vm.max_map_count=262144 sysctl -p # Linux 配置结束 mkdir -p ~/elk/elasticsearch/plugins mkdir -p ~/elk/elasticsearch/data mkdir -p ~/elk/logstash chmod 777 ~/elk/elasticsearch/data vim ~/elk/logstash/logstash.conf # 见下文 vim ~/elk/docker-compose.yml # 见下文 docker-compose up -dlogstash.conf
input { tcp { mode => "server" host => "0.0.0.0" port => 4560 codec => json_lines } } output { elasticsearch { hosts => "es:9200" index => "springboot-logstash-demo-%{+YYYY.MM.dd}" } }docker-compose.yml
version: '3' services: elasticsearch: image: docker.elastic.co/elasticsearch/elasticsearch:7.16.2 container_name: elasticsearch volumes: - ~/elk/elasticsearch/plugins:/usr/share/elasticsearch/plugins #插件文件挂载 - ~/elk/elasticsearch/data:/usr/share/elasticsearch/data #数据文件挂载 environment: - "cluster.name=elasticsearch" #设置集群名称为elasticsearch - "discovery.type=single-node" #以单一节点模式启动 - "ES_JAVA_OPTS=-Xms512m -Xmx512m" #设置使用jvm内存大小 - "ingest.geoip.downloader.enabled=false" # (Dynamic, Boolean) If true, Elasticsearch automatically downloads and manages updates for GeoIP2 databases from the ingest.geoip.downloader.endpoint. If false, Elasticsearch does not download updates and deletes all downloaded databases. Defaults to true. ports: - 9200:9200 logstash: image: docker.elastic.co/logstash/logstash:7.16.2 container_name: logstash volumes: - ~/elk/logstash/logstash.conf:/usr/share/logstash/pipeline/logstash.conf #挂载logstash的配置文件 depends_on: - elasticsearch #kibana在elasticsearch启动之后再启动 links: - elasticsearch:es #可以用es这个域名访问elasticsearch服务 ports: - 4560:4560 kibana: image: docker.elastic.co/kibana/kibana:7.16.2 container_name: kibana depends_on: - elasticsearch #kibana在elasticsearch启动之后再启动 links: - elasticsearch:es #可以用es这个域名访问elasticsearch服务 environment: - "elasticsearch.hosts=http://es:9200" #设置访问elasticsearch的地址 ports: - 5601:5601在logstash中安装json_lines插件
# 进入logstash容器 docker exec -it logstash /bin/bash # 进入bin目录 cd /bin/ # 安装插件 logstash-plugin install logstash-codec-json_lines # 退出容器 exit # 重启logstash服务 docker restart logstash修改logback-spring.xml
pom.xml引入依赖${LOGSTASH_SERVCE} { "service_name":"${SERVICE_NAME}", "server_flag":"${SERVER_FLAG}" } 5 minutes
net.logstash.logback logstash-logback-encoder7.0.1
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)