prometheus監控實戰( 三 )

啟動
nohup ./bin/logstash -f ./pipelines/log_collect.conf 1>nohup.loog 2>nohup.log &3.3、部署客戶端filebeat日志格式如下
gtms-switch-center 2022-04-19 17:28:14.616 [http-nio-8080-exec-989] INFO  c.p.switchcenter.web.controller.SwitchController1、linux系統

  • 安裝
tar -xvf filebeat.tar.gzcd filebeat/
  • 編寫配置文件
vi filebeat.ymlfilebeat.prospectors:  - input_type: log    paths:      - /bankapp/switch/gtms-switch-center/com.pactera.jep.log.biz*.log    multiline:      pattern: '^gtms-switch-center'      negate: true      match: after      max_lines: 200      timeout: 20s    fields:      env: "prd001"      appid: "switch"      appname: "switch"      hostip: "192.168.10.15"    reload.enabled: true    reload.period: 2Sfields_under_root: trueoutput.logstash:  hosts: ["192.168.10.11:10515" ]  enabled: true
  • 啟動
nohup ./filebeat -e -c filebeat.yml -d "publish" 1>/dev/null 2>&1 &2、windows系統
  • windows安裝直接解壓即可,解壓如下
    prometheus監控實戰

    文章插圖
  • 編寫配置文件filebeat.yml
filebeat.prospectors:  - input_type: log    encoding: gbk    paths:      - C:/bankapp/switch/gtms-switch-center/com.pactera.jep.log.biz*.log    multiline:      pattern: '^gtms-switch-center'      negate: true      match: after      max_lines: 200      timeout: 20s    fields:      env: "prd001"      appid: "switch"      appname: "switch"      hostip: "192.168.10.16"    reload.enabled: true    reload.period: 2S    fields_under_root: trueoutput.logstash:  hosts: ["192.168.10.11:10515" ]  enabled: true
  • 編寫后臺啟動腳本startFilebeat.vbs
set ws=WScript.CreateObject("WScript.Shell")ws.Run "filebeat.exe -e -c filebeat.yml",0
  • 啟動 , 雙擊腳本startFilebeat.vbs
    prometheus監控實戰

    文章插圖
3.4、grafana查看日志用grafana查看日志,可以根據自己的刪選條件(關鍵字、時間等)選擇查詢響應的日志信息,具體如圖
prometheus監控實戰

文章插圖
prometheus監控實戰

文章插圖
prometheus監控實戰

文章插圖
第四節、自定義監控自定義監控可以根據自己編寫的腳本,把需要監控的監控指標發送到pushgateway上,最后存儲在promethues,使用grafana查看 。
4.1、pushgateway1、部署pushgateway
tar -xvf pushgateway-1.4.2.linux-amd64.tar.gzcd pushgateway-1.4.2.linux-amd64/啟動
nohup ./pushgateway --web.listen-address=:48888 1>nohup.log 2>&1 &2、promethues集成pushgateway
  • 編輯配置文件vi prometheus.yml
  - job_name: 'pushgateway'    static_configs:      - targets: [‘192.168.10.10:48888']        labels:          instance: pushgateway