[Elasticsearch] Metricbeat 설치 및 연동

Jaewon Lim·2025년 4월 13일

Elasticsearch

목록 보기
5/12
post-thumbnail

[과제]
1. metricbeats → ES(3 node cluster) → kibana discover 확인
2. metricbeats → logstash → ES(3 node cluster) → kibana discover 확인
[버전]
8.17.4 tar
[서버]
192.168.219.159 (master) : Elasticsearch, Kibana, Logstash, CA 인증서
192.168.219.157 (data) : Elasticsearch, Metricbeat
192.168.219.158 (data) : Elasticsearch

Metricbeat-8.17.4 (tar 설치)

  1. Metricbeat 설치 (node-3 서버에 설치, 192.168.219.158)
[elastic@localhost ~]$ wget https://artifacts.elastic.co/downloads/beats/metricbeat/metricbeat-8.17.4-linux-x86_64.tar.gz
[elastic@localhost ~]$ tar -xzf metricbeat-8.17.4-linux-x86_64.tar.gz
[elastic@localhost ~]$ cd metricbeat-8.17.4-linux-x86_64
  1. Metricbeat.yml 수정
vi metricbeat.yml

# metricbeat.yml
output.elasticsearch:
  hosts: ["https://192.168.219.159:9200"] # ES에 데이터를 보낼 주소
	ssl:
		enabled: true # TLS 통신을 활성화. ES가 보안 모드일 때 필수
		ca_trusted_fingerprint: "{fingerprint}" #ES 인증서, http_ca.crt 설치 시 ì¶œë ¥ëœ SHA256 ê°’



  preset: balanced

  # Protocol - either `http` (default) or `https`.
  #protocol: "https"

  # Authentication credentials - either API key or username/password.
  #api_key: "id:api_key"
  username: "elastic"
  password: "elastic"
  1. 유저(Elastic) sudo 권한 주기

    Metricbeat처럼 시스템 정보를 수집하는 도구는 루트 수준의 접근 권한이 필요한 경우가 많아, sudo 권한 설정이 필요하다. Metricbeat는 CPU, 메모리, 프로세스, 디스크 I/O, 시스템 서비스 등 커널 레벨 또는 시스템 리소스를 직접 접근해서 데이터를 수집

su - root
visudo

# /etc/sudoers
elastic ALL=(ALL) NOPASSWD: /home/elastic/metricbeat-8.17.4-linux-x86_64/metricbeat
  • NOPASSWD 있음 : 뒤에 내용만 sudo 로 사용할 수 있고, 비밀번호는 입력하지 않아도 됨
  • NOPASSWD 대신 ALL : 모든 명령어를 sudo로 실행 가능. 🔥 완전한 관리자 권한 부여(보안 위험)
  1. 시스템 메트릭 활성화
  • modules.d/system.yml.disabled → modules.d/system.yml로 활성화
  • 즉, 시스템 관련 CPU, memory, disk, process 정보 등을 수집하도록 설정을 켜주는 것
cd /home/elastic/metricbeat-8.17.4-linux-x86_64
./metricbeat modules enable system

Metricbeat 실행

  1. Metricbeat 실행
# 비밀번호 없이 실행 가능, 시스템 메트릭을 정상적으로 수집
sudo ./metricbeat -e 

#대시보드 초기화 명령어, metricbeat.yml에서 Kibana 설정필요
sudo ./metricbeat setup -e
  • -e
    • -e 옵션은 metricbeat의 로그를 터미널에서 볼 수 있게 해줌
    • -e 옵션으로 정상 실행을 모니터링 후 ./metricbeat & 와 같이 데몬으로 실행하거나 yum 등으로 metricbeat를 설치 후 systemctl로 서비스를 시작 가능

주의 사항

✅ Logstash가 먼저 열려 있어야, beat(Filebeat/Metricbeat)가 데이터를 전송할 “문”이 열리는 것과 같다.

./bin/logstash -f config/metric.conf
sudo ./metricbeawt -e -c metricbeat.yml

0개의 댓글