filebeat配置中的unmarshal错误

时间:2015-12-07 09:57:25

标签: yaml logstash elastic-stack

我已为logstash配置了filebeat。但是在启动文件时我遇到了以下错误:

main.go:42: CRIT Config error: Error reading config file: YAML config parsing failed on /etc/filebeat/filebeat.yml: yaml: unmarshal errors:
  line 2: cannot unmarshal !!str `paths:
...` into []config.ProspectorConfig. Exiting.

我已在其他具有相同配置的服务器上配置了filebeat,并且它运行正常,但我不明白为什么我在此服务器上出现此语法错误。

以下是配置文件:

filebeat:
  prospectors: |-
    paths:
    '/var/log/*.log'
  registry_file: /var/lib/filebeat/registry
  config_dir: /etc/filebeat/conf.d
output:
  elasticsearch:
    enabled: false
    hosts:
    - 52.35.55.85:9200
  logstash:
    enabled: true
    hosts:
    - 52.32.18.237:5044
  file:
    enabled: false
    path: /tmp/filebeat
    filename: filebeat
    rotate_every_kb: 1000
    number_of_files: 7

1 个答案:

答案 0 :(得分:3)

我对filebeat(甚至Go,真的)一无所知,但是这条错误信息:

cannot unmarshal !!str `paths:
...` into []config.ProspectorConfig. Exiting.

...告诉我,它将paths值视为一个序列(数组的YAML用语),而不是标量(字符串)。而不是:

paths:
'/var/log/*.log'

...试试这个:

paths:
- '/var/log/*.log'

...或者,因为引号在这里是无关紧要的:

paths:
- /var/log/*.log