Docker 배치 ELK 사용 하기

8193 단어 DockerElasticSearch
GitHub 주소
docker-compose.yml 파일 편집
version: '3.2'

services:
  elasticsearch:
    image: docker.elastic.co/elasticsearch/elasticsearch:7.6.0
    container_name: elasticsearch7.6.0
    environment:
      - discovery.type=single-node
      - "ES_JAVA_OPTS=-Xms512m -Xmx512m"
    volumes:
      - esdata:/usr/share/elasticsearch/data
    hostname: elasticsearch
    restart: always
    ports:
      - "9200:9200"
      - "9300:9300"

  logstash:
    image: docker.elastic.co/logstash/logstash:7.6.0
    container_name: logstash7.6.0
    environment:
      LS_JAVA_OPTS: "-Xmx256m -Xms256m"
    volumes:
      - type: bind
        source: ./logstash/config/logstash.yml
        target: /usr/share/logstash/config/logstash.yml
        read_only: true
      - type: bind
        source: ./logstash/pipeline #   logstash.conf    
        target: /usr/share/logstash/pipeline
        read_only: true
      - type: bind
        source: /application/elk/elk7.6.0/movies   #        
        target: /logs                              # docker      
    hostname: logstash
    restart: always
    depends_on:
      - elasticsearch
    ports:
      - "5000:5000"
      - "9600:9600"

  kibana:
    image: docker.elastic.co/kibana/kibana:7.6.0
    container_name: kibana7.6.0
    environment:
      - elasticsearch.hosts=http://elasticsearch:9200
      - I18N_LOCALE=zh-CN
      - XPACK_GRAPH_ENABLED=true
      - TIMELION_ENABLED=true
      - XPACK_MONITORING_COLLECTION_ENABLED="true"
    hostname: kibana
    restart: always
    depends_on:
      - elasticsearch
    ports:
      - "5601:5601"


volumes:
  esdata:
    driver: local


logstash\pipeline 디 렉 터 리 에 logstash.conf 파일 추가
input {
  file {
    #         logstash       ,          volume        
    path => "/logs/movies.csv"
    start_position => "beginning"
    sincedb_path => "/dev/null"
  }
}
filter {
  csv {
    separator => ","
    columns => ["id","content","genre"]
  }

  mutate {
    split => { "genre" => "|" }
    remove_field => ["path", "host","@timestamp","message"]
  }

  mutate {

    split => ["content", "("]
    add_field => { "title" => "%{[content][0]}"}
    add_field => { "year" => "%{[content][1]}"}
  }

  mutate {
    convert => {
      "year" => "integer"
    }
    strip => ["title"]
    remove_field => ["path", "host","@timestamp","message","content"]
  }

}
output {
   elasticsearch {
     hosts => "elasticsearch:9200"
     index => "movies"
     document_id => "%{id}"
   }
  stdout {}
}



logstash\\config 경로 에 logstash.yml 파일 추가:
http.host: "0.0.0.0"

docker-compose 명령
#   
docker-compose up -d
#   
docker-compose stop
#   
docker-compose logs service_name

docker 용기 가 작 동 되면 localhost:5601 을 방문 하면 kibana 에 데이터 가 있 음 을 발견 할 수 있 습 니 다.

좋은 웹페이지 즐겨찾기