redis 모니터링을 위해 logstash 사용하여 elk와 연결

 

1. logstash 수집 설정

 

input {
        exec {
                command => "redis-cli -c -p 6379 -a password info clients"
                interval => 60
                type => "m1"
        }

        exec {
                command => "redis-cli -c -p 7379 -a password info stats"
                interval => 60
                type => "s3"
        }

}

 

filter {
        mutate {
                gsub => [ "message", "\r", "" ]                           => \r를 ""로 대체
        }

        split {
                remove_field => [ "command", "tags" ]                 => command, tags 제거
        }
        if [message] =~ /^#/ {                                              => comment 항목 제거
                drop{}
        }

        ruby {
                code => "def is_number? string
                                true if Float(string) rescue false
                             end

                             fields = event.get('message').split(':')

                             if is_number?( fields[1] )

                                event.set(fields[0], fields[1].to_f)

                             else

                                event.set(fields[0], fields[1])

                             end"

         }

}

 

output {

        stdout { codec => rubydebug { metadata => true } }

        elasticsearch {
                hosts => ["10.10.10.20:9200", "10.10.10.21:9200"]
                index => "sinfa-%{type}-%{+YYYYMMdd}"            => 일일 테이블로 생성                   
        }
}

'Cache > redis' 카테고리의 다른 글

redis conf 정보  (2) 2020.06.03
redis cluster 구성  (0) 2017.05.02
redis 운영 명령어  (0) 2017.04.20

+ Recent posts