티스토리 뷰
Metricbeat
💡 정말 삽질 of 삽질.. 기본적으로 Document를 따라가며 세팅해야함. 정리한 내용은 문제가 생겼던 부분 위주로 정리
Guide Document
Metricbeat quick start: installation and configuration | Metricbeat Reference [8.1] | Elastic
Collecting Elasticsearch monitoring data with Metricbeat | Elasticsearch Guide [8.1] | Elastic
기본구조 및 세팅 Point
- 운영 cluster → 모니터링데이터를 수집
- metricbeat install
metricbeat.yml
setting- modules setting (
modules.d/*.yml
)
- 모니터링 cluster (elasticsearch) → 수집한 모니터링 데이터를 적재
- 방화벽 open (수집 node에서 쏘는 데이터를 받기 위해서)
참고로, 아래 예시는 싱글 node 기준이라 별도 방화벽 세팅은 없음
- output.elasticsearch 로 세팅될 cluster
- elasticsearch 인증서를 Copy 해주어야함 (Monitoring Cluster → Production Cluster)
- 방화벽 open (수집 node에서 쏘는 데이터를 받기 위해서)
- (참고) 기본구조 도식
세팅을 진행하며 발생하는 문제를 해결해 가는 방법
💡 서버이전을 하면서 ELK 7.x → ELK 8 version upgrade 도 동시에 진행을 해보았는데 만약 마이그레이션을 하더라도 이전 세팅은 믿지 않는 편이 좋다..
💡 documentation 과 log 를 보면서 답을 찾아가야함
💡 특히, 8 버전부터(?) elasticsearch 접속이 기본적으로 인증서 인증을 지원하는 것 같아 7.x에 야매로 세팅한 업보 때문에 어려움이 있었다..
로그보면서 해결..
### systemd 로그관련 명령어 ## systemd status systemctl status metricbeat ## systemd 로그 tracking journalctl -f ## 실제로 서비스를 start 하기 그렇다면 setup 명령을 통해서도 확인가능해 보인다. metricbeat setup -e
curl 명령 확인하고 세팅..
접속 및 인증 방식이 여러개라서 반드시 세팅하려는 접속방식이 실제로 접속이 되는지
curl
명령어로 먼저 확인하자참고
https://www.elastic.co/guide/en/cloud-enterprise/2.12/ece-api-command-line.html#ece-api-command-line### 인증서 + Id/PASSWORD 접속 확인 curl --cacert /etc/elasticsearch/certs/http_ca.crt -u elastic https://localhost:9200/_cat/indices?v curl --cacert /etc/elasticsearch/certs/http_ca.crt -u remote_monitoring_user https://localhost:9200/_cat/indices?v ######################################################################### ### API Key 접속 확인 ## api_key data 인코딩 # echo -n <api_key_ID>:<api_key> | base64 echo -n qwp...ec1:YR...QPw | base64 # cX...ReZ...Vdw== ## 접속 명령 #=> $ECE_API_KEY = 인코딩된 값 # curl -k -X GET -H "Authorization: ApiKey $ECE_API_KEY" curl -k -X GET -H "Authorization: ApiKey cX...ReZ...Vdw==" https://localhost:9200/_cluster/health\?pretty curl -k -H "Authorization: ApiKey cX...ReZ...Vdw==" https://localhost:9200/_cluster/health\?pretty
Secure setting
metricbeat keystore
metricbeat keystore 명령어를 통해 config 파일에 직접 password, api_key를 입력시 보안상 취약하기 때문에 keystore 등록 후 세팅
관련 document
## keystore List Keys metricbeat keystore list ## keystore Add keys metricbeat keystore add MB_PWD # Enter value for MB_PWD: (입력) ## keystore Remove keys metricbeat keystore remove ES_PWD
api_key 발급 방법
api_key 관련 세팅을 보면 예시가 있음
하지만, 예시 그대로 하면 안되는 경우가 존재하기 때문에 error log 보면서 변경
주로, privileges 권한관련 내용이 문제가 되며, 보안사항을 고려해 권한을 변경하면 해결해야한다.
### kibana devtool # 발급 api_key 조회 GET /_security/api_key # 특정 api_key 제거(invalidate) DELETE /_security/api_key { "name" : "metricbeat_host001" }
### kibana devtool ## api_key 발급요청 POST /_security/api_key { "name": "metricbeat_host002", "role_descriptors": { "metricbeat_writer": { "cluster": ["monitor", "read_ilm", "read_pipeline", "manage"], "index": [ { "names": ["metricbeat-*"], "privileges": ["view_index_metadata", "create_doc"] } ] } } } ## 결과 { "id" : "wQu...iX", "name" : "metricbeat_host002", "api_key" : "DNW...Qg", "encoded" : "d1F...Zw==" }
elasticsearch 경로에 기본적으로 생성되는 인증서 Copy
- 모니터링할 node의 module 에 접근시 인증서가 필요한 경우 Copy한 경로의 인증서를 사용
# /etc/elasticsearch/certs/http_ca.crt cp /etc/elasticsearch/certs/http_ca.crt [복사할 경로]
metricbeat.yml
setting
- 모니터링할 node의 module 에 접근시 인증서가 필요한 경우 Copy한 경로의 인증서를 사용
https://
접근을 해야하는 경우 url 유의 (아래 둘 중 하나 가능)## http output.elasticsearch: # hosts: ["http://localhost:9200"] ######################################################################### ## https setting-1 output.elasticsearch: # Array of hosts to connect to. hosts: \["https://localhost:9200"\] # Protocol - either `http` (default) or `https`. protocol: "https" ######################################################################### ## https setting-2 output.elasticsearch: # Array of hosts to connect to. hosts: ["localhost:9200"] # Protocol - either `http` (default) or `https`. protocol: "https"
elasticsearch 접속 인증관련 세팅
- ID/PASSWORD + 인증서
- API_KEY + 인증서
output.elasticsearch: (( host 명, http 프로토콜 세팅 )) # Authentication credentials - either API key or username/password. #api_key: "id:api_key" api_key: "${MB_API_KEY}" #username: "elastic" #password: "changeme" ssl.certificate_authorities: "/etc/metricbeat/certs/http_ca.crt" #ssl.verification_mode: none
(참고) Set to true to enable config reloading
- module config 파일 변경시 metricbeat 를 restart 하지 않아도 됨
# Set to true to enable config reloading
reload.enabled: true
# Period on which files under path should be checked for changes
reload.period: 10s
modules.d/*.yml
setting
metricbeat modules enable elasticsearch-xpack
metricbeat modules enable logstash-xpack
- module config 예시
- elasticsearch-xpack.yml
- module: elasticsearch xpack.enabled: true period: 10s hosts: \["https://localhost:9200"\] username: "remote\_monitoring\_user" password: "${REMOTE\_USER\_PWD}" ssl.certificate\_authorities: \["/etc/metricbeat/certs/http\_ca.crt"\]
- elasticsearch-xpack.yml
- logstash-xpack.yml
- ssl 세팅이 되어 있지 않아서
http://
로 접근- module: logstash xpack.enabled: true period: 10s metricsets: \["node", "node\_stats"\] hosts: \["http://localhost:9600"\] username: "remote\_monitoring\_user" password: "${REMOTE\_USER\_PWD}" #ssl.certificate\_authorities: \["/etc/metricbeat/certs/http\_ca.crt"\]
- ssl 세팅이 되어 있지 않아서
- Total
- Today
- Yesterday
- metricbeat
- 애플워치 액세서리
- 코로나19
- 일반투자기업
- 애플워치6
- 24주적금
- 마켓컬리
- 네이버
- 퇴근길page2정리
- 쿠팡
- 경제신의신과함께
- 라이언머그컵
- log4j2
- elasticstack
- 샤인마토
- 쿠팡프레시
- 국민연금
- golang정규식
- 한정판굿즈
- 애플워치 거치대
- 애플액세서리 추천
- 휘점
- YELLOWGIFT
- java
- 일반투자
- 고양이는귀여워
- 애플워치se
- 애플워치 스포츠루프
- 대설주위보
- 자바스크립트정규식
일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
1 | 2 | 3 | 4 | 5 | ||
6 | 7 | 8 | 9 | 10 | 11 | 12 |
13 | 14 | 15 | 16 | 17 | 18 | 19 |
20 | 21 | 22 | 23 | 24 | 25 | 26 |
27 | 28 | 29 | 30 |