August 09, 2022
Summary
# docker-compose.yml 파일 version: '2' services: remotebeat: restart: always container_name: remotebeat image: docker.elastic.co/logstash/logstash-oss:7.10.2 env_file: - .env environment: - bootstrap.memory_lock=true - "LS_JAVA_OPTS=-Xms2g -Xmx2g" volumes: - ./config/remotebeat/logstash.yml:/usr/share/logstash/config/logstash.yml - ./config/remotebeat/pipelines.yml:/usr/share/logstash/config/pipelines.yml - ./config/remotebeat/pipeline/:/usr/share/logstash/pipeline/ - ./config/remotebeat/remotebeat-data:/usr/share/logstash/data/ - ./config/remotebeat/files/:/usr/share/logstash/files/ network_mode: host user: 0:0 command: --config.reload.automatic # .env REMOTE_SITE=CHANGE_ME REMOTE_KAFKA_HOST=127.0.0.1:7710 COMPOSE_PROJECT_NAME=REMOTEBEAT # config/remotebeat/logstash.yml http.host: 0.0.0.0 pipeline.workers: 1 # config/remotebeat/pipelines.yml - pipeline.id: logstash pipeline.workers: 2 path.config: "/usr/share/logstash/pipeline/logstash.conf" # config/remotebeat/pipeline/logstash.conf input { file { path => "/usr/share/logstash/files/test.txt" start_position => "beginning" stat_interval => 1 type => textfile } } output { stdout { codec => rubydebug } stdout { codec => json } http { url => "http://127.0.0.1:49154/v2/log" http_method => "post" format => "json" mapping => [ "message", "%{message}"] } } # config/remotebeat/files/test.txt logstash test txt files read # docker-compose.yml 위치에서 명령어 입력 docker-compose up
01.로그 스태시 docker-compose.yml 파일
02.볼륨 준비
02.0 .env
02.1 config/remotebeat/
logstash.yml
02.2 config/remotebeat/
pipelines.yml
02.3 config/remotebeat/pipeline/
logstash.conf
02.4 config/remotebeat/files/
test.txt
03.remotebeat 실행하기
remotebeat에서 찍히는 것
API 콘솔에서 찍히는것
version: '2'
services:
remotebeat:
restart: always
container_name: remotebeat
image: docker.elastic.co/logstash/logstash-oss:7.10.2
env_file:
- .env
environment:
- bootstrap.memory_lock=true
- "LS_JAVA_OPTS=-Xms2g -Xmx2g"
volumes:
- ./config/remotebeat/logstash.yml:/usr/share/logstash/config/logstash.yml
- ./config/remotebeat/pipelines.yml:/usr/share/logstash/config/pipelines.yml
- ./config/remotebeat/pipeline/:/usr/share/logstash/pipeline/
- ./config/remotebeat/remotebeat-data:/usr/share/logstash/data/
- ./config/remotebeat/files/:/usr/share/logstash/files/
network_mode: host
user: 0:0
command: --config.reload.automatic
config | 폴더
pipeline | 폴더
files | 폴더
REMOTE_SITE=CHANGE_ME
REMOTE_KAFKA_HOST=127.0.0.1:7710
COMPOSE_PROJECT_NAME=REMOTEBEAT
사실상 REMOTESITE=CHANGEME, REMOTEKAFKAHOST=127.0.0.1:7710
logstash.yml
http.host: 0.0.0.0
pipeline.workers: 1
#log.level: debug
pipelines.yml
- pipeline.id: logstash
pipeline.workers: 2
path.config: "/usr/share/logstash/pipeline/logstash.conf"
logstash.conf
input {
file {
path => "/usr/share/logstash/files/test.txt"
start_position => "beginning"
stat_interval => 1
type => textfile
}
}
output {
stdout { codec => rubydebug }
stdout { codec => json }
http {
url => "http://127.0.0.1:49154/v2/log"
http_method => "post"
format => "json"
mapping => [ "message", "%{message}"]
}
}
test.txt
logstash test txt files read
docker-compose.yml 파일 있는 위치로 이동
docker-compose up
혹시나 위에처럼 api에서 못받아온다면 test.txt 파일 자체를 변경해주자