Hugh's Blog

Docker ELK 配置

 

docker-compose.yml

version: "3.3"

services:
  elasticsearch:
    image: elasticsearch:6.4.3
    environment:
      LOGSPOUT: ignore
      ES_JAVA_OPTS: "-Xmx256m -Xms256m"
    volumes:
      - ./elasticsearch.yml:/usr/share/elasticsearch/config/elasticsearch.yml:ro
    ports:
      - "9200:9200"

  logstash:
    image: logstash:6.4.3
    environment:
      LOGSPOUT: ignore
    volumes:
      - ./temp.log:/var/log/temp.log
      - ./logstash.conf:/etc/logstash.conf
    ports:
      - "5000:5000"
    links:
      - elasticsearch
    command: -f /etc/logstash.conf

  kibana:
    image: kibana:6.4.3
    environment:
      LOGSPOUT: ignore
      ELASTICSEARCH_URL: http://elasticsearch:9200
    volumes:
      - ./elasticsearch.yml:/usr/share/elasticsearch/config/elasticsearch.yml:ro
    ports:
      - "5601:5601"
    links:
      - elasticsearch

elasticsearch.yml

http.port: 9200
network.host: 0.0.0.0
discovery.type: single-node

logstash.conf

input {
  file {
    path => ["/var/log/temp.log"]
  }
}
output {
  elasticsearch {
    hosts => ["elasticsearch:9200"]
  }
}