用于filebeats的Nginx模块不会解析访问日志

时间:2017-07-18 10:19:36

标签: elasticsearch nginx elastic-stack filebeat

我正在使用nginx模块进行文件绑定,以便将日志数据发送到elasticsearch。这是我的文件配置:

output:
  logstash:
    enabled: true
    hosts:
      - logstash:5044
    timeout: 15

filebeat.modules:
- module: nginx
  access:
    enabled: true
    var.paths: ["/var/log/nginx/access.log"]
  error:
    enabled: true
    var.paths: ["/var/log/nginx/error.log"]

问题是没有解析日志。这就是我在Kibana看到的:

{   "_index": "filebeat-2017.07.18",   "_type": "log",   "_id": "AV1VLXEbhj7uWd8Fgz6M",   "_version": 1,   "_score": null,   "_source": {
    "@timestamp": "2017-07-18T10:10:24.791Z",
    "offset": 65136,
    "@version": "1",
    "beat": {
      "hostname": "06d09033fb23",
      "name": "06d09033fb23",
      "version": "5.5.0"
    },
    "input_type": "log",
    "host": "06d09033fb23",
    "source": "/var/log/nginx/access.log",
    "message": "10.15.129.226 - - [18/Jul/2017:12:10:21 +0200] \"POST /orders-service/orders/v1/sessions/update/FUEL_DISPENSER?api_key=vgxt5u24uqyyyd9gmxzpu9n7 HTTP/1.1\" 200 5 \"-\" \"Mashery Proxy\"",
    "type": "log",
    "tags": [
      "beats_input_codec_plain_applied"
    ]   },   "fields": {
    "@timestamp": [
      1500372624791
    ]   },   "sort": [
    1500372624791   ] }

我缺少已解析的字段,如文档中所述:https://www.elastic.co/guide/en/beats/filebeat/current/exported-fields-nginx.html

为什么没有解析日志行?

1 个答案:

答案 0 :(得分:4)

当您运行filebeat -v -modules=nginx -setup时,它基本上会创建4件事:

  • 映射模板
  • kibana仪表板
  • machineLearning job
  • 过滤器节点中的过滤器

以下是解析过滤器:
- nginx access log
- nginx error log

过滤器存储在摄取节点中。您可以访问它们:
http://YourElasticHost:9200/_ingest/pipeline

因此,如果您希望解析日志,则需要通过摄取节点发送它们。