赞
踩
ELK
├── docker-compose.yml
├── elasticsearch
│ ├── data
│ ├── logs
│ └── plugins
├── kibana
│ └── config
│ └── kibana.yml
└── logstash
├── config
│ └── logstash.yml
└── pipeline
└── logstash.conf
version: '3' services: elasticsearch: image: elasticsearch:7.17.2 container_name: elasticsearch networks: - network_elk_test ports: - "9200:9200" environment: cluster.name: elasticsearch discovery.type: single-node ES_JAVA_OPTS: "-Xms512m -Xmx512m" volumes: - ./elasticsearch/plugins:/usr/share/elasticsearch/plugins - ./elasticsearch/data:/usr/share/elasticsearch/data - ./elasticsearch/logs:/usr/share/elasticsearch/logs kibana: image: kibana:7.17.2 container_name: kibana networks: - network_elk_test ports: - "5601:5601" depends_on: - elasticsearch environment: I18N_LOCALE: zh-CN volumes: - ./kibana/config/kibana.yml:/usr/share/kibana/config/kibana.yml logstash: image: logstash:7.17.2 container_name: logstash networks: - network_elk_test ports: - "4560:4560" volumes: - ./logstash/pipeline/logstash.conf:/usr/share/logstash/pipeline/logstash.conf - ./logstash/config/logstash.yml:/usr/share/logstash/config/logstash.yml depends_on: - elasticsearch networks: network_elk_test: name: ELKTest
server.host: "0.0.0.0"
server.shutdownTimeout: "5s"
elasticsearch.hosts: [ "http://elasticsearch:9200" ]
monitoring.ui.container.elasticsearch.enabled: true
server.publicBaseUrl: "http://kibana:5601"
http.host: "0.0.0.0"
xpack.monitoring.elasticsearch.hosts: [ "http://elasticsearch:9200" ]
pipeline.ecs_compatibility: v1
input {
tcp {
mode => "server"
host => "0.0.0.0"
port => 4560
codec => json_lines
}
}
output {
stdout { codec => rubydebug }
elasticsearch {
hosts => "elasticsearch:9200"
index => "%{appName}-%{+YYYY.MM.dd}" #索引名
}
}
<dependency>
<groupId>net.logstash.logback</groupId>
<artifactId>logstash-logback-encoder</artifactId>
<version>7.1.1</version>
</dependency>
<?xml version="1.0" encoding="UTF-8"?> <configuration debug="false"> <property name="LOG_HOME" value="logs/demo.log"/> <appender name="STDOUT" class="ch.qos.logback.core.ConsoleAppender"> <encoder class="ch.qos.logback.classic.encoder.PatternLayoutEncoder"> <pattern>%d{yyyy-MM-dd HH:mm:ss.SSS} [%thread] %-5level %logger{50} - %msg%n</pattern> </encoder> </appender> <springProperty scope="context" name="appName" source="spring.application.name"/> <appender name="logstash" class="net.logstash.logback.appender.LogstashTcpSocketAppender"> <!--指定logstash的ip及端口--> <destination>XX.XX.XX.XX:4560</destination> <encoder class="net.logstash.logback.encoder.LogstashEncoder"> <customFields>{"spring.application.name":"${appName}"}</customFields> </encoder> </appender> <root level="INFO"> <appender-ref ref="STDOUT"/> <appender-ref ref="logstash"/> </root> </configuration>
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。