조금씩 다른 구성으로 파일을 작성하는데 아래와 같이 작업하면 되는 듯 하다. (테스트 해보지 않았다.)
도커 컴포즈를 이용해 아래 파일로 이미지를 빌드하는 경우에는 여전히 에러가 해소가 되지 않아서 나는 도커 파일 없이 작업했다.
# Dockerfile
FROM docker.elastic.co/beats/filebeat:7.10.0
COPY /config/filebeat.yml /usr/share/filebeat/filebeat.yml
USER root
RUN chmod go-w /usr/share/filebeat/filebeat.yml
RUN chown -R root /usr/share/filebeat
filebeat.yml
로그 파일 위치를 세팅하고, 엘라스틱 서치로 전송하도록 구성했다.
# ============================== Filebeat inputs ===============================
filebeat.inputs:
- type: log
id: api-log # API 로그
fields:
index_name: "api-log"
enabled: true
paths: - /var/log/spring/*.json
json.keys_under_root: true
json.overwrite_keys: true
json.add_error_key: true
json.expand_keys: true
- type: log
id: api-log # API 로그
fields:
index_name: "nginx-log"
enabled: true
paths: - /var/log/nginx/*.log
# ================================== Outputs ===================================
# ------------------------------ OpenSearch Output ------------------------------
output.elasticsearch:
hosts: ["{대충 주소}.es.amazonaws.com:443"] # 443 포트로 연결 / 포트 안 넣어두면 자동으로 9200 포트로 전송하니 꼭 포트 정보도 적는다.
protocol: "https"
username: "{username}"
password: "{password}"
index: "{}" # 인덱스 설정이 없으면, filebeat-yyyymmdd 대충 이런 형태로 기본 설정된다.
#
setup.ilm.enabled: false
setup.pack.security.enabled: false
setup.xpack.graph.enabled: false
setup.xpack.watcher.enabled: false
setup.xpack.monitoring.enabled: false
setup.xpack.reporting.enabled: false