[Fluentd] Consumer2

AnHyunDong·2022년 6월 27일
0

개요

  • 실시간 크롤링한 뉴스 데이터를 전달할 플랫폼이 필요함
  • Consumer를 Fluentd를 사용할 예정
  • Kafka -> Fluentd -> Elastic Search로 전달 예정
  • 따라서 Consumer를 표준출력을 ES로 보내기 위해 conf파일 수정 예정

제한사항

  • topic 이름은 news(대문자가 들어가면 안됨)
  • 보낼 데이터(네이버 뉴스)
    • 뉴스 제목
    • 신문사
    • 뉴스 장르(정치, IT, 생활, 세계 등 6개)
    • 뉴스 url
  • ES로 전달 예정

Code

  • /etc/td-agent/td-agent.conf에서 코드 수정
  • @ 뒤에 연결할 방법을 입력
  • <source> : 데이터 받는 부분 > Consumer 역할
  • <match> : 데이터를 전달하는 부분 > elasticsearch 즉, elasticsearch로 보냄
  • include_timestamp true : 시간 데이터를 포함해 보냄
<source>
  @type kafka

  brokers kafka2-59655564bd-cmfjg:9092
  format json
  tag news

  <topic>
    topic news
  </topic>

</source>

<match news>
  @type elasticsearch
  host 182.20.167.56
  port 9200
  include_timestamp true
  index_name news
  type_name fluentd
</match>

결과

URL

실시간 뉴스

profile
사진은 남아 추억이 메모는 남아 스펙이 된다

0개의 댓글