[ELK] Python - Kafka - Logstash - Elasticsearch - Kibana

이정훈·2023년 3월 23일
0

ELK

목록 보기
4/4
post-thumbnail

ptyhon

from kafka import KafkaProducer

import time

producer = KafkaProducer(
    bootstrap_servers=['200.200.200.5:9092']
)

start = time.time()

for i in range(100):
  
    producer.send('testing', value="받아랏".encode("utf-8")) # 토픽은 testing
    producer.flush()


print("elapsed :", time.time() - start)
  • 파이썬은 카쿠카에게 토픽과 내용을 전달해준다

kafka

  • 카프카 서버는 작동만 되고 있으면 된다. 이 친구의 역할은 현재 broker!

logstash

	vi /etc/logstash/conf.d/kafka.conf
input {
    kafka {
        bootstrap_servers =>  "200.200.200.5:9092" # 파이썬이 카프카에게 보냈으니 여기서 받아야함
        group_id => "logstash"
        topics => ["testing"]
        consumer_threads => 1
    }
}

output {
  elasticsearch {
    hosts => ["http://200.200.200.70:9200"] # 엘라스틱여기에 저장할 것이고
    index => "kafka-test-%{+YYYY-MM-dd}" # 인덱스는 kafka-test~ 으로 할 것임
  }
}

elasticsearch

  • postman으로 확인한 결과 잘 전달된 것을 확인 할 수 있다.

kibana

  • 키파바에서도 인덱스가 저장된 것을 확인 할 수 있다.

search!

elasticsearch

  • 플러그인 설치
/usr/share/elasticsearch/bin/elasticsearch-plugin install analysis-nori
systemctl restart elasticsearch
  • 플러그인 test
    포스트맨으로 실시
  • 검색하기 위한 방법을 plugin 해줬고
    그냥 분석했을 떄이다.
  • 노리를 적용했을 때 노리만의 분석방법으로 나눈 것이다.

초성으로 확인하기!

  • 초성검색가능 플러그인 설치
/usr/share/elasticsearch/bin/elasticsearch-plugin install file:///root/hanhinsam-0.1.zip
    
systemctl restart elasticsearch
profile
싱숭생숭늉

0개의 댓글