FILEBEAT+ELK日志收集平台搭建流程 (6)

{"jv_time": "2018 09 29 20:16:32.672","jv_level": "INFO","jv_thread": "MQClientFactoryScheduledThread", "jv_class": "RocketmqClient", "jv_method": "sendHeartbeatToAllBroker","jv_message": "send heart beat to broker[broker-a 0 8bet-test-srv-2:10911] success","jv_throwable": ""}

 

(3)、filebeat的安装与配置:

$wget https://artifacts.elastic.co/downloads/beats/filebeat/filebeat-6.4.0-linux-x86_64.tar.gz

         $ tar -zxf filebeat-6.4.0-linux-x86_64.tar.gz

         $ mv filebeat-6.4.0-linux-x86_64 filebeat

         $ vim filebeat/filebeat.yml

filebeat.inputs:

 

- type: log

 

  paths:

 

    - /log/nginx/8bet.admin.log

 

  fields:

 

    project: 8bet-admin

 

    server_ip: 192.168.41.4

 

    server_name: 8bet-test-srv-4

 

    soft: nginx

 

  fields_under_root: true

 

- type: log

 

  paths:

 

    - /log/nginx/8bet.h5.log

 

  fields:

 

    project: 8bet-h5

 

    server_ip: 192.168.41.4

 

    server_name: 8bet-test-srv-4

 

    soft: nginx

 

  fields_under_root: true

 

- type: log

 

  paths:

 

    - /log/nginx/8bet.newadmin.log

 

  fields:

 

    project: 8bet-newadmin

 

    server_ip: 192.168.41.4

 

    server_name: 8bet-test-srv-4

 

    soft: nginx

 

  fields_under_root: true

 

- type: log

 

  paths:

 

    - /log/nginx/8bet.newh5.log

 

  fields:

 

    project: 8bet-newh5

 

    server_ip: 192.168.41.4

 

    server_name: 8bet-test-srv-4

 

    soft: nginx

 

  fields_under_root: true

 

- type: log

 

  paths:

 

    - /log/nginx/error.log

 

  fields:

 

    project: 8bet-nginx-error

 

    server_ip: 192.168.41.4

 

    server_name: 8bet-test-srv-4

 

    soft: nginx

 

  fields_under_root: true

 

- type: log

 

  paths:

 

    - /log/billing/info.log

 

  fields:

 

    project: 8bet-java-billing

 

    server_ip: 192.168.41.4

 

    server_name: 8bet-test-srv-4

 

    soft: java

 

  fields_under_root: true

 

- type: log

 

  paths:

 

    - /log/billing/error.log

 

  fields:

 

    project: 8bet-java-billing

 

    server_ip: 192.168.41.4

 

    server_name: 8bet-test-srv-4

 

    soft: java

 

  fields_under_root: true

#error日志多行可配置项

#  multiline.pattern: '^\{'

#  multiline.negate: true

#  multiline.match: after

 

- type: log

 

  paths:

 

    - /log/member/info.log

 

  fields:

 

    project: 8bet-java-member

 

    server_ip: 192.168.41.4

 

    server_name: 8bet-test-srv-4

 

    soft: java

 

  fields_under_root: true

 

- type: log

 

  paths:

 

    - /log/member/error.log

 

  fields:

 

    project: 8bet-java-member

 

    server_ip: 192.168.41.4

 

    server_name: 8bet-test-srv-4

 

    soft: java

 

  fields_under_root: true

 

- type: log

 

  paths:

 

    - /log/admin/info.log

 

  fields:

 

    project: 8bet-java-admin

 

    server_ip: 192.168.41.4

 

    server_name: 8bet-test-srv-4

 

    soft: java

 

  fields_under_root: true

 

- type: log

 

  paths:

 

    - /log/admin/error.log

 

  fields:

 

    project: 8bet-java-admin

 

    server_ip: 192.168.41.4

 

    server_name: 8bet-test-srv-4

 

    soft: java

 

  fields_under_root: true

 

- type: log

 

  paths:

 

    - /log/pay/info.log

 

  fields:

 

    project: 8bet-java-pay

 

    server_ip: 192.168.41.4

 

    server_name: 8bet-test-srv-4

 

    soft: java

 

  fields_under_root: true

 

- type: log

 

  paths:

 

    - /log/pay/error.log

 

  fields:

 

    project: 8bet-java-pay

 

    server_ip: 192.168.41.4

 

    server_name: 8bet-test-srv-4

 

    soft: java

 

  fields_under_root: true

 

- type: log

 

  paths:

 

    - /log/discount/info.log

 

  fields:

 

    project: 8bet-java-discount

 

    server_ip: 192.168.41.4

 

    server_name: 8bet-test-srv-4

 

    soft: java

 

  fields_under_root: true

 

- type: log

 

  paths:

 

    - /log/discount/error.log

 

  fields:

 

    project: 8bet-java-discount

 

    server_ip: 192.168.41.4

 

    server_name: 8bet-test-srv-4

 

    soft: java

 

  fields_under_root: true

 

- type: log

 

  paths:

 

    - /log/schedule/info.log

 

  fields:

 

    project: 8bet-java-schedule

 

    server_ip: 192.168.41.4

 

    server_name: 8bet-test-srv-4

 

    soft: java

 

  fields_under_root: true

 

- type: log

 

  paths:

 

    - /log/schedule/error.log

 

  fields:

 

    project: 8bet-java-schedule

 

    server_ip: 192.168.41.4

 

    server_name: 8bet-test-srv-4

 

    soft: java

 

  fields_under_root: true

 

- type: log

 

  paths:

 

    - /log/security/info.log

 

  fields:

 

    project: 8bet-java-security

 

    server_ip: 192.168.41.4

 

    server_name: 8bet-test-srv-4

 

    soft: java

 

  fields_under_root: true

 

- type: log

 

  paths:

 

    - /log/security/error.log

 

  fields:

 

    project: 8bet-java-security

 

    server_ip: 192.168.41.4

 

    server_name: 8bet-test-srv-4

 

    soft: java

 

  fields_under_root: true

 

- type: log

 

  paths:

 

    - /log/caipiao/info.log

 

  fields:

 

    project: 8bet-java-caipiao

 

    server_ip: 192.168.41.4

 

    server_name: 8bet-test-srv-4

 

    soft: java

 

  fields_under_root: true

 

- type: log

 

  paths:

 

    - /log/caipiao/error.log

 

  fields:

 

    project: 8bet-java-caipiao

 

    server_ip: 192.168.41.4

 

    server_name: 8bet-test-srv-4

 

    soft: java

 

  fields_under_root: true

 

- type: log

 

  paths:

 

    - /log/cpbilling/info.log

 

  fields:

 

    project: 8bet-java-cpbilling

 

    server_ip: 192.168.41.4

 

    server_name: 8bet-test-srv-4

 

    soft: java

 

  fields_under_root: true

 

- type: log

 

  paths:

 

    - /log/cpbilling/error.log

 

  fields:

 

    project: 8bet-java-cpbilling

 

    server_ip: 192.168.41.4

 

    server_name: 8bet-test-srv-4

 

    soft: java

 

  fields_under_root: true

 

- type: log

 

  paths:

 

    - /log/cpmessage/info.log

 

  fields:

 

    project: 8bet-java-cpmessage

 

    server_ip: 192.168.41.4

 

    server_name: 8bet-test-srv-4

 

    soft: java

 

  fields_under_root: true

 

- type: log

 

  paths:

 

    - /log/cpmessage/error.log

 

  fields:

 

    project: 8bet-java-cpmessage

 

    server_ip: 192.168.41.4

 

    server_name: 8bet-test-srv-4

 

    soft: java

 

  fields_under_root: true

 

- type: log

 

  paths:

 

    - /log/cpschedule/info.log

 

  fields:

 

    project: 8bet-java-cpschedule

 

    server_ip: 192.168.41.4

 

    server_name: 8bet-test-srv-4

 

    soft: java

 

  fields_under_root: true

 

- type: log

 

  paths:

 

    - /log/cpschedule/error.log

 

  fields:

 

    project: 8bet-java-cpschedule

 

    server_ip: 192.168.41.4

 

    server_name: 8bet-test-srv-4

 

    soft: java

 

  fields_under_root: true

 

filebeat.config.modules:

 

  path: ${path.config}/modules.d/*.yml

 

  reload.enabled: false

 

setup.template.settings:

 

  index.number_of_shards: 3

 

setup.kibana:

 

output.logstash:

 

  hosts: ["8bet-test-srv-6:5044"]

 

         启动:

         $ /data/soft/filebeat/filebeat -c /data/soft/filebeat/filebeat.yml &

         PS:最后将elk和filebeat的相关命令写入到启动脚本简化操作。

4、         REST API方式操作:

常用的几种操作示例:

$ curl -XGET 'localhost:9200/_cat/health?v&pretty=true'

$ curl -XPUT 'localhost:9200/laptops'

$curl -XPUT 'localhost:9200/laptops/doc/1?pretty&pretty' -H 'Content-Type: application/json' -d ‘{ "title": "Laptop X1 i7 8gb RAM " }’

$curl -XPUT 'localhost:9200/laptops/doc/2?pretty&pretty' -H 'Content-Type: application/json' -d ‘{ "title": "Laptop X2 i5 4gb RAM " }’

$ curl -XGET 'localhost:9200/laptops/_search?pretty=true' -H 'Content-Type: application/json'

$ curl -XDELETE 'localhost:9200/laptops/?pretty=true'

 

 

 

以下部分为摘录网上文档部分【提供参考】:

 

内容版权声明:除非注明,否则皆为本站原创文章。

转载注明出处:https://www.heiqu.com/zwjxdz.html