一. filebeat分别收集Nginx正常和错误日志
filebeat配置文件:
filebeat.inputs: - type: log enabled: true paths: - /var/log/nginx/access.log json.keys_under_root: true json.overwrite_keys: true tags: ["access"] - type: log enabled: true paths: - /var/log/nginx/error.log tags: ["error"] setup.kibana: host: "10.0.0.31:5601" output.elasticsearch: hosts: ["10.0.0.31:9200"] #index: "nginx-%{[beat.version]}-%{+yyyy.MM}" indices: - index: "nginx_access-%{[beat.version]}-%{+yyyy.MM}" when.contains: tags: "access" - index: "nginx_error-%{[beat.version]}-%{+yyyy.MM}" when.contains: tags: "error" setup.template.name: "nginx" setup.template.pattern: "nginx-*" setup.template.enabled: false setup.template.overwrite: true
2.filebeat配收集omcat日志
配置文件
1 filebeat.inputs: 2 ############nginx############## 3 - type: log 4 enabled: true 5 paths: 6 - /var/log/nginx/access.log 7 json.keys_under_root: true 8 json.overwrite_keys: true 9 tags: ["access"] 10 11 - type: log 12 enabled: true 13 paths: 14 - /var/log/nginx/error.log 15 tags: ["error"] 16 17 #############tomcat############### 18 19 - type: log 20 enabled: true 25 tags: ["tomcat"] 26 27 #############output############### 28 29 setup.kibana: 30 host: "10.0.0.31:5601" 31 32 output.elasticsearch: 33 hosts: ["10.0.0.31:9200"] 34 #index: "nginx-%{[beat.version]}-%{+yyyy.MM}" 35 indices: 36 - index: "nginx_access-%{[beat.version]}-%{+yyyy.MM}" 37 when.contains: 38 tags: "access" 39 - index: "nginx_error-%{[beat.version]}-%{+yyyy.MM}" 40 when.contains: 41 tags: "error" 42 - index: "tomcat_access-%{[beat.version]}-%{+yyyy.MM}" 43 when.contains: 44 tags: "tomcat" 45 46 ###########nginx模板############### 47 setup.template.name: "nginx" 48 setup.template.pattern: "nginx-*" 49 setup.template.enabled: false 50 setup.template.overwrite: true 51 ###########tomcat模板############## 52 setup.template.name: "tomcat" 53 setup.template.pattern: "tomcat-*" 54 setup.template.enabled: false 55 setup.template.overwrite: true