환경/Logstash

[Logstash] Metricbeats의 데이터를 받아서 ElasticSearch로 전송

yesman9 2023. 9. 22. 18:02

이 글은 아래 포스팅에서 이어지는 글이다.

https://wonseok.tistory.com/37

 

Metricbeat을 이용해 시스템 메트릭 수집 (with Logstash)

Metricbeat 설치가 안되어있다면 아래 링크를 참고하길 바란다. https://wonseok.tistory.com/36 Metricbeat 설치 내 경우에는 Elasticsearch와 Kibana는 다른 서버에 이미 설치되어있으므로 이것의 설치는 생략한다.

wonseok.tistory.com

 


 

이 포스팅은 이미 운용중인 Logstash를 기준으로 한다.

Logstash 설치 및 초기 셋팅은 다른 글을 참고하길 바란다.

 


 

나의 경우에는 Metricbeat을 여러 서버로부터 받기때문에, 어떤 Metric인지 구분할 필요가 있다.

내가 선택한 방법은 포트별로 따로 받아서 tags를 이용해 각각 처리하는 방법이다.

[Logstash] 포트별로 따로 받아서 tags를 이용해 각각 처리

 

로그스태시 conf파일을 아래와같이 편집한다.

input {

    beats {
        port => 5044

        tags => ["metric_5044"]
    }   

    beats {
        port => 1125

        tags => ["metric_1125"]
    }

output {

    if "metric_5044" in [tags] {
        elasticsearch {
            hosts => ["host1:9200", "host2:9200", "host3:9200"]
            index => "index_metric_5044"
            user => "user"
            password => "password"
        }

        stdout {}
    }

    if "metric_1125" in [tags] {
        elasticsearch {
            hosts => ["host1:9200", "host2:9200", "host3:9200"]
            index => "index_metric_1125"
            user => "user"
            password => "password"
        }

        stdout {}
    }

}

 

Kibana에 접속해서 index를 확인해보면 생성되어있는 것을 확인할 수 있다.