Vector 테스트 – Yongbok Blog
Yongbok Blog

Vector 테스트

1. Vector 설치

 

bash ~# curl -o '/opt/vector.tar.gz' \
-L "https://packages.timber.io/vector/0.20.0/vector-0.20.0-x86_64-unknown-linux-musl.tar.gz"
bash ~# tar xzvf vector.tar.gz -C /opt/vector
bash ~# mv /opt/vector-x86_64-unknown-linux-musl /opt/vector

2. Bash Profile 설정

 

bash ~# vi $HOME/.bash_profile
# Vector profile
export VECTOR_HOME="/opt/vector"
export PATH=$PATH:$VECTOR_HOME/bin
bash ~# source $HOME/.bash_profile

3. Vector 설정 파일 예제

 

본인 Mirror 서버의 HAProxy Custom 파일 로그를 기반으로 테스트

bash ~# mkdir /opt/vector/data
bash ~# cat << EOF > $VECTOR_HOME/config/vector.toml
#                                    __   __  __
#                                    \ \ / / / /
#                                     \ V / / /
#                                      \_/  \/
#
#                                    V E C T O R
#                                   Configuration
#
# ------------------------------------------------------------------------------
# Website: https://vector.dev
# Docs: https://vector.dev/docs
# Chat: https://chat.vector.dev
# ------------------------------------------------------------------------------

# Change this to use a non-default directory for Vector data storage:
data_dir = "/opt/vector/data"

# Enable API
[api]
enabled = true

#### Input ####
[sources.haproxy_custom_json_logs]
type = "file"
include = [ "/var/log/rsyslog/haproxy/mirror-*.log" ]
read_from = "beginning"

#### Output ####
[sinks.output_logs]
type = "file"
inputs = [ "haproxy_custom_json_logs" ]
compression = "none"
encoding.codec = "text"
path = "/data/haproxy/mirror.log"
EOF

4. Vector 실행

 

source -> transforms -> sinks의 정의 기반으로 로그를 수집하여 파일을 구분하여 떨군다.

bash ~# vector -vv --config $VECTOR_HOME/config/vector.toml

– Vector: Input

 

– Vector: Output

 

Exit mobile version