아마존 영역에서 elasticsearch를 사용하기 위해서는 opensearch를 사용해야되는데 기존 elasticsearch 와 연동하는 부분이 라이센스 문제 때문에 삽질을 계속했다.  

logstash에서 opensearch로 데이터를 전송하기 위해서는 logstash-oss 다운받아야 하며 opensearch 모듈이 포함되어 있는 것을 다운 받아야 한다. (https://opensearch.org/downloads.html)

curl https://artifacts.opensearch.org/logstash/logstash-oss-with-opensearch-output-plugin-7.16.2-linux-x64.tar.gz -o logstash-oss-with-opensearch-output-plugin-7.16.2-linux-x64.tar.gz

tar -zxvf logstash-oss-with-opensearch-output-plugin-7.16.2-linux-x64.tar.gz

로그스태시 생성

/home/ec2-user/logstash-7.16.2/config/logstash.conf 파일 생성

input {
  file {
    path => ["/log/*.log"]
    start_position => "beginning"
  }
}
filter {
    json {
      source => "message"
      remove_field => ["message", "@timestamp", "@version"]
    }
}
output {
     opensearch {
        hosts       => ["https://:443"]
        user        => "user"
        password    => "password"
        index       => "logstash-logs"
    }
}

로그스태시  실행 

/home/ec2-user/logstash-7.16.2/bin/logstash -f /home/ec2-user/logstash-7.16.2/config/test.conf

+ Recent posts