Data Store/Elastic Stack
[FileBeat] 설치 및 테스트
전봉근
2019. 5. 22. 14:22
반응형
[filebeat 설치]
1. https://www.elastic.co/downloads/beats/filebeat 접속하여 다운
- wget -qO - https://artifacts.elastic.co/GPG-KEY-elasticsearch | sudo apt-key add -
- sudo apt-get install apt-transport-https
- echo "deb https://artifacts.elastic.co/packages/5.x/apt stable main" | sudo tee -a /etc/apt/sources.list.d/elastic-5.x.list
- sudo apt-get update && sudo apt-get install filebeat
2. filebeat config설정(/etc/filebeat/filebeat.yml)
[설정 1 - log경로]
- input_type: log
# Paths that should be crawled and fetched. Glob based paths.
paths:
#- /var/log/*.log
- /opt/tomcat/logs/catalina.out
#- c:\programdata\elasticsearch\logs\*
[설정 2 - 어디로 보낼지 경로 설정]
output.logstash:
# The Logstash hosts
hosts: ["YOUR_LOGSTASH_IP:5044"]
3. logstash config 설정(/etc/logstash/conf.d/logstash.conf)
// filebeat은 기본적으로 5044 port를 사용한다.
// output은 예를들어 LB아래 여러 톰캣서버를 돌릴경우 호스트네임별로 조건을 넣는다.
// index => "tomcat-%{+YYYY.MM.dd}" 매일과 같이 새로운 인덱스 로그 생성
# [logstash.conf]
input {
beats {
port => 5044
}
}
output {
if [beat][hostname] == "ip-172-31-30-178" or [beat][hostname] == "ip-172-31-30-179" {
elasticsearch {
hosts => "13.125.41.125:9200"
manage_template => false
index => "tomcat-%{+YYYY.MM.dd}"
document_type => "%{[@metadata][type]}"
}
}
else if [beat][hostname] == "ip-172-31-30-180" {
elasticsearch {
hosts => "13.125.41.125:9200"
manage_template => false
index => "database-%{+YYYY.MM.dd}"
document_type => "%{[@metadata][type]}"
}
}
else {
elasticsearch {
hosts => "13.125.41.125:9200"
manage_template => false
index => "%{[@metadata][beat]}-%{+YYYY.MM.dd}"
document_type => "%{[@metadata][type]}"
}
}
}
4. logstash 및 filebeat 재시작하고 kibana에서 log 확인.
반응형