본문 바로가기

리눅스

[리눅스] Metricbeat 설치하는 방법

728x90

Metricbeat 설치하는 방법

Metricbeat 패키지 설치

yum install --enablerepo=elasticsearch -y metricbeat

Metricbeat(metricbeat.yml) 설정 확인

cat /etc/metricbeat/metricbeat.yml | egrep -v '^$|^#|#'
$ cat /etc/metricbeat/metricbeat.yml | egrep -v '^$|^#|#'
metricbeat.config.modules:
  path: ${path.config}/modules.d/*.yml
  reload.enabled: false
setup.template.settings:
  index.number_of_shards: 1
  index.codec: best_compression
setup.kibana:
output.elasticsearch:
  hosts: ["localhost:9200"]
processors:
  - add_host_metadata: ~
  - add_cloud_metadata: ~
  - add_docker_metadata: ~
  - add_kubernetes_metadata: ~

Metricbeat에서 Elasticsearch x-pack 모듈 활성화 및 구성

cd /etc/metricbeat
$ ls -l modules.d/ | grep elasticsearch-xpack
-rw-r--r-- 1 root root  261 Feb 12 13:40 elasticsearch-xpack.yml.disabled
/usr/bin/metricbeat modules enable elasticsearch-xpack
$ ls -l modules.d/ | grep elasticsearch-xpack
-rw-r--r-- 1 root root  261 Feb 12 13:40 elasticsearch-xpack.yml

메트릭 수집 모듈 활성화 및 구성

metricbeat modules list
$ metricbeat modules list
Enabled:
elasticsearch-xpack
system

Disabled:
activemq
aerospike
...

elasticsearch 모듈 활성화

metricbeat modules enable elasticsearch

kibana 모듈 활성화

metricbeat modules enable kibana

metricbeat 서비스 재시작

systemctl --now enable metricbeat

metricbeat 서비스 상태 확인

systemctl status metricbeat

Metricbeat 구성하기

vim /etc/metricbeat/metricbeat.yml
output.elasticsearch:
  # Array of hosts to connect to.
  hosts: ["localhost:9200"]

  # 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"
systemctl restart metricbeat

elasticsearch index

curl -sk https://elastic:elastic@localhost:9200/_cat/indices?v | grep metricbeat
$ curl -sk https://elastic:elastic@localhost:9200/_cat/indices?v | grep metricbeat
yellow open   .ds-metrics-elastic_agent.metricbeat-default-2023.03.16-000001    LgE_P1K6Q4Kwbm5IRn-vhg   1   1       3093            0    687.7kb        687.7kb
yellow open   .ds-logs-elastic_agent.metricbeat-default-2023.03.16-000001       gxZRNEF_SV6UTLvss-o39w   1   1       1857            0    553.5kb        553.5kb

키바나 대시보드 설치

metricbeat setup --dashboards

 

 

참고URL

- setup repositories : https://www.elastic.co/guide/en/beats/metricbeat/8.6/setup-repositories.html

 

728x90