"reason"=>"failed to parse field [message] of type [text] in document with id '3UI29IEBerapX-zaQi4L'.
Preview of field's value:
...중략...
"caused_by"=>{"type"=>"illegal_state_exception", "reason"=>"Can't get text on a
START_OBJECT at 1:529"}
이런 에러메시지를 접하게 되면 두 눈 크게 뜨고 Template 에서 정의한 type 정보와 실제 들어 오는 값이 잘 매핑이 되어 있는지 확인을 해보시기 바랍니다.
# 기본 설정 예시
$ vi filebeat.yml
# 아래 설정에서 inode_marker 파일은 미리 생성이 되어 있어야 에러가 발생 하지 않습니다.
filebeat.inputs:
- type: filestream
id: fb-filestream
enabled: true
paths:
- $[PATH}/logs/*.log
file_identity.inode_marker.path: $[PATH}/logs/.filebeat-marker
encoding: utf-8
processors:
- decode_json_fields:
fields: [ "message" ]
target: "json"
output.elasticsearch:
hosts: ["localhost:9200"]
# 실행
$ ./filebeat -c filebeat.yml -e
4. Logstash Setup
filebeat 연동 시 filebeat.yml 의 output 에 logstash 설정을 합니다.
# filebeat 설치 경로에 가서 수정 합니다.
$ vi filebeat.yml
output.logstash:
hosts: ["localhost:5044"]
# 이제 logstash 와 filebeat 연동을 위한 설정을 합니다.
$ vi config/logstash-sample.conf
input {
beats {
port => 5044
}
}
output {
elasticsearch {
hosts => ["http://localhost:9200"]
index => "logstash-%{+YYYY.MM.dd}"
}
}
# 이제 logtash 와 filebeat 를 실행 해서 정상적으로 색인이 되었는지 확인 합니다.
$ bin/logstash -f config/logstash-sample.conf
# pipeline.yml 을 사용하기 위해서는 아래 설정 후 실행 하면 됩니다.
# 기본 설정이기 때문에 한번은 해야 합니다.
$ vi config/logstash.yml
node.name: ${NODE-NAME}
path.data: ${PATH}/data/logstash
path.logs: ${PATH}/logs/logstash
config.reload.automatic: true
config.reload.interval: 60s
http.port: 9600
$ vi config/pipeline.yml
- pipeline.id: filebeat-log-pipeline
pipeline.workers: 4
pipeline.batch.size: 20
path.config: "${PATH}/config/logstash-sample.conf"
# 이제 실행 합니다.
$ bin/logstash