[Devops] ELK Beat template (8.11.0) - ubuntu 22.04

2023. 11. 30. 15:54·개발/Devops
728x90
반응형

ELK 구축후 각 인스턴스에 세팅해줄 템플릿

0-1. 호스트 네임 설정

sudo hostnamectl set-hostname [호스트 이름]

0-2. 인스턴스 시간 설정 (서울)

sudo timedatectl set-timezone Asia/Seoul

1. metric beat 세팅 - CPU, 메모리, 디스크 사용량

(1) metric beat 설치

curl -L -O https://artifacts.elastic.co/downloads/beats/metricbeat/metricbeat-8.11.0-amd64.deb
sudo dpkg -i metricbeat-8.11.0-amd64.deb
sudo apt-get update

(2) metric beat 설정

sudo rm -rf /etc/metricbeat/metricbeat.yml
sudo vi /etc/metricbeat/metricbeat.yml
setup.kibana:
  host: "[kibana host]:443"
  username: "elastic"
  password: "password"

output.logstash:
  hosts: ["logstashhost:port"]
  ssl.enabled: true

processors:
  - add_host_metadata: ~

metricbeat.modules:
- module: system
  metricsets:
    - cpu
    - memory
    - network
    - fsstat
  period: 30s

(3) metric beat 실행

sudo systemctl start metricbeat.service
sudo systemctl enable metricbeat.service
sudo systemctl status metricbeat.service

2. filebeat 설치 - application log 전송

(1) filebeat 설치

curl -L -O https://artifacts.elastic.co/downloads/beats/filebeat/filebeat-8.11.0-amd64.deb
sudo dpkg -i filebeat-8.11.0-amd64.deb

(2) filebeat 설정

sudo rm -rf /etc/filebeat/filebeat.yml
sudo vi /etc/filebeat/filebeat.yml
filebeat.inputs:
  - type: log
    enabled: true
    paths:
      - 전체로그경로.log # 전체 쌓는 로그 경로
    fields:
      log_level: info

  - type: log
    enabled: true
    paths:
      - 에러로그경로.log # 에러 로그 경로
    fields:
      log_level: error

setup.kibana:
  host: "[kibana host]:443"
  username: "elastic"
  password: "password"

output.logstash:
  hosts: ["logstash host"]
  ssl.enabled: true

processors:
  - add_host_metadata: ~

(3) filebeat 실행

sudo systemctl start filebeat.service
sudo systemctl enable filebeat.service
sudo systemctl status filebeat.service

3. heartbeat 설정

(1) ping 허용

Aws security 인바운드 규칙 추가 -> Custom ICMP - ip는 logstash ip 받으면 됨.

(2) heartbeat 설치 - logstash 서버에 설치하기 때문에 application 서버는 해당사항 없음.

curl -L -O https://artifacts.elastic.co/downloads/beats/heartbeat/heartbeat-8.11.0-amd64.deb
sudo dpkg -i heartbeat-8.11.0-amd64.deb

(3) heartbeat.yml

sudo rm -rf /etc/heartbeat/heartbeat.yml
sudo vi /etc/heartbeat/heartbeat.yml
heartbeat.monitors:
- type: icmp
  id: icmp-monitor
  name: filebeat-test
  hosts: ["monitoring할 서버ip"]
  schedule: '@every 30s'

setup.kibana:
  host: "[kibana host]"
  username: "elastic"
  password: "password"


output.logstash:
  hosts: ["localhost:5044"]
sudo systemctl start heartbeat-elastic.service 

4. 결과

(1) metricbeat - 30초

(2) filebeat - 10초에 한번씩 로그 파일이 변경되는지 확인

(3) heartbeat(ICMP) 30초

(4) 최종 logstash.conf 파일

input {

  beats {
    port => 5044
    host => "0.0.0.0"
  }

}

filter {
  if [agent][type] == "heartbeat" {
    mutate {
      add_field => { "[host][hostname]" => "%{[monitor][name]}" }
    }
  }
}

output {

  elasticsearch {
    hosts => ["es host"]
    index => "%{[@metadata][beat]}-%{[@metadata][version]}-%{+YYYY.MM.dd}"
    user => "elastic"
    password => "password"
  }
}
728x90
반응형

'개발 > Devops' 카테고리의 다른 글

[Devops] ELK APM으로 성능측정하기 - ubuntu 22.04  (0) 2023.12.04
[Devops] ElasticeSearch에서 잔디 Webhook 연결 - ubuntu 22.04  (0) 2023.11.30
[Devops] ELK 디스크 부족 이슈 S3로 해결하기 - ubuntu 22.04  (0) 2023.11.23
[Devops] ELK Stack 8.x 설치 - ubuntu 22.04  (0) 2023.11.13
[Devops] spring boot 블루/그린 무중단 배포 (gitlab ci, docker, nginx)  (0) 2023.06.19
'개발/Devops' 카테고리의 다른 글
  • [Devops] ELK APM으로 성능측정하기 - ubuntu 22.04
  • [Devops] ElasticeSearch에서 잔디 Webhook 연결 - ubuntu 22.04
  • [Devops] ELK 디스크 부족 이슈 S3로 해결하기 - ubuntu 22.04
  • [Devops] ELK Stack 8.x 설치 - ubuntu 22.04
TeTedo.
TeTedo.
  • TeTedo.
    TeTedo 개발 일기
    TeTedo.
  • 전체
    오늘
    어제
    • 분류 전체보기 (319)
      • 개발 (274)
        • Article (4)
        • 정리 (21)
        • Spring Boot (17)
        • JPA (2)
        • JAVA (6)
        • Database (4)
        • 자료구조 (11)
        • 알고리즘 (32)
        • React (20)
        • Docker (10)
        • node.js (18)
        • Devops (11)
        • Linux (4)
        • TypeScript (3)
        • Go (10)
        • HyperLedger (4)
        • BlockChain (43)
        • html, css, js (48)
        • CS (3)
        • AWS (3)
      • 모아두고 나중에 쓰기 (3)
      • 팀프로젝트 (18)
        • SNS(키보드워리어) (9)
        • close_sea (9)
      • 개인프로젝트 (1)
        • Around Flavor (1)
        • CHAM (13)
        • ethFruitShop (5)
      • 독서 (0)
        • 스프링부트와 AWS로 혼자 구현하는 웹 서비스 (0)
  • 블로그 메뉴

    • 홈
    • 개발일기
    • CS
    • 실습
    • 코딩테스트
    • 웹
    • Go
    • node.js
    • 팀플
  • 링크

  • 공지사항

  • 인기 글

  • 태그

    React
    js
    30일 챌린지
    블록체인
    go언어
    ERC721
    node.js
    하이퍼레저
    erc20
    30일챌린지
    nodejs
    프로그래머스
    명령어
    mysql
    CSS
    도커
    node
    컨테이너
    html
    go
  • 최근 댓글

  • 최근 글

  • hELLO· Designed By정상우.v4.10.1
TeTedo.
[Devops] ELK Beat template (8.11.0) - ubuntu 22.04
상단으로

티스토리툴바