ELK 설치 하고 실습 하기 3 - logstash & Filebeats 설치

2017. 6. 16. 17:17DB&NoSQL/Elasticsearch,ELK

logstash & Filebeats 설치
아래 모든 설치 전에 사전에 java 최소 버전은 8이어야 한다고 당부 . 

*주의!!! 
이 문서는 ELK에 있는 getting started Guide을 되는대로 번역을 해 놓은 것입니다. (장담할수없어요.. 참고만 하세요)
    • 설치
      • 다운로드 : https://www.elastic.co/downloads/logstash
      • 설치 가이드 : https://www.elastic.co/guide/en/logstash/current/getting-started-with-logstash.html
      • 첫번째 이벤트를 stash 하는 법을 배운후에, 아파치 웹 로그을 가져오는 보다 발전된 파이프 라이인을 생성하는 것을 진행합니다.
        (input, parses the logs , writes the parsed data to an Elasticsearch cluster)
      • 분리된 소스들의 다양성으로 부터 데이터를 통합하는 다중 input 과 output 플러그인을 함께  stitch 하는 법을 배우게 됩니다.
      • stashing your first event

        • Logstash pipeline은 input 과 output 그리고 옵션 요소인 filter 의  필수 요소를 가지고 있습니다.
          • input 플러그인은 소스로 부터 데이터를 소비합니다.
          • filter 플러그인은 우리가 명시한것으로 데이터를 수정합니다.
          • output 플러그인은 목적지에 데이터를 작성합니다.

        • Logstash 설치를 테스트 하기 위해서는 , 가장 일반적인 Logstash 파이프 라인을 아래와 같이 기동해봅니다.
          -e 플래그는 command line에서 직접 configuration을 명시할수 있습니다.

          logstash-5.4.1 $ bin/logstash -e 'input { stdin { } } output { stdout { } }'
          Sending Logstash's logs to D:/logstash-5.4.1/logs which is now configured via log4j2.properties
          [2017-06-09T10:31:31,800][INFO ][logstash.agent           ] No persistent UUID file found. Generating new UUID {:uuid=>"f7563343-9339-4799-b723-566e664ab13d", :path=>"D:/logstash-5.4.1/data/uuid"}
          [2017-06-09T10:31:31,971][INFO ][logstash.pipeline        ] Starting pipeline {"id"=>"main", "pipeline.workers"=>4, "pipeline.batch.size"=>125, "pipeline.batch.delay"=>5, "pipeline.max_inflight"=>500}
          [2017-06-09T10:31:32,009][INFO ][logstash.pipeline        ] Pipeline main started
          The stdin plugin is now waiting for input:
          [2017-06-09T10:31:32,099][INFO ][logstash.agent           ] Successfully started Logstash API endpoint {:port=>9600}

        • 아래 구조의 예제 파이프라인은 stdin : 표준 입력으로부터 input을 받고,stdout :표준 출력에 input을 이동합니다.  
          Logstash를 시작하고, "Pipeline main started" 가 보일 때까지 기다렸다가, "Hello world"을 입력해보시길.

          Hello world
          2017-06-09T01:37:55.998Z DESKTOP-F8QJRCK Hello world

        • Logstash는 timestamp 와 IP 주소 정보를 message에 추가 합니다.
          CTRL-D 을 통해 Logstash 탈출. (windows 는 CTRL-Z 였다)