页面“Blackbox exporter”与“Filebeat nginx log”之间的差异

来自linux中国网wiki
(页面间的差异)
跳到导航 跳到搜索
 
 
第1行: 第1行:
=* intra=
+
[[category:ops]]
Blackbox Exporter是Prometheus社区提供的官方黑盒监控解决方案,其允许用户通过:HTTP、HTTPS、DNS、TCP以及ICMP的方式对网络进行探测
 
=* install=
 
==** From source==
 
==** Using Docker==
 
docker-compose 自带了 也可以自己安装在其它机器上
 
==** 官方下载包解压和自己手工写sysd启动脚本==
 
==**  visa==
 
直接 ip:9115 或者如下作ng proxy_pass
 
  
http://blackbox.com/metrics
+
=ins and config=
 +
==Download and install Filebeat==
 +
<pre>
  
http://blackbox.com/probe?target=prometheus.io&module=http_2xx
 
  
为1 成功  0 不成功
+
curl -L -O https://artifacts.elastic.co/downloads/beats/filebeat/filebeat-7.12.0-amd64.deb
或者Logs 查看日志
+
sudo dpkg -i filebeat-7.12.0-amd64.deb
=* conf=
+
</pre>
 +
==Edit the configuration ==
 
<pre>
 
<pre>
这个可以参考 laradock 用变量哦
+
Modify /etc/filebeat/filebeat.yml to set the connection information:
#填写你的 blackboxip,可能和我的不一样
 
vim  prometheus/prometheus.yml
 
 
 
        #replacement: "10.3.10.124:9115"  # Blackbox exporter.
 
        replacement: "blackbox_exporter:9115"  # Blackbox exporter.
 
  
重载
+
output.elasticsearch:
curl -X POST http://127.0.0.1:9090/-/reload
+
  hosts: ["<es_url>"]
 +
  username: "elastic"
 +
  password: "<password>"
 +
setup.kibana:
 +
  host: "<kibana_url>"
  
<http_probe>可配置参数 有空要看一下加强一下
+
Where <password> is the password of the elastic user, <es_url> is the URL of Elasticsearch, and <kibana_url> is the URL of Kibana.
  
# 目标的HTTP基本身份验证凭据。
 
  basic_auth:
 
    [ username: <string> ]
 
    [ password: <secret> ]
 
 
</pre>
 
</pre>
  
=* grafana =
+
==Enable and configure the nginx module ==
  
grafana  7587 
+
<pre>
 +
sudo filebeat modules enable nginx
  
9965号模板,数据源选择Prometheus 模板下载地址 https://grafana.com/grafana/dashboards/9965
+
Modify the settings in the /etc/filebeat/modules.d/nginx.yml file.
  
可以直接进去容器里面安装
+
</pre>
此模板需要安装饼状图插件 下载地址 https://grafana.com/grafana/plugins/grafana-piechart-panel
 
安装插件,重启grafana生效。
 
  
grafana-cli plugins install grafana-piechart-panel
+
== Start Filebeat==
service grafana-server restart
 
 
 
https://blog.csdn.net/shykevin/article/details/103527945
 
 
 
5345 好像有点老
 
https://grafana.com/grafana/dashboards/5345
 
=*  实例了=  
 
==** http post==
 
 
 
 
 
https://market-api.126.com/api/v1/market/coin/rank/thirty
 
 
 
 
 
https://blog.csdn.net/qq_25934401/article/details/84325356
 
 
 
 
 
=* 配置参考 =
 
<pre> cp config.yml config.ymltodaygood
 
#add to config.yml
 
  - job_name: 'blackbox'
 
    metrics_path: /probe
 
    params:
 
      module: [http_2xx]  # Look for a HTTP 200 response.
 
    static_configs:
 
      - targets:
 
        - https://hk.search.yahoo.com
 
        #- https://pagertree.com
 
        #- https://prometheus.io
 
        labels:
 
          instance: user_status
 
          grop: 'web'
 
    relabel_configs:
 
      - source_labels: [__address__]
 
        target_label: __param_target
 
      - source_labels: [__param_target]
 
        target_label: instance
 
      - target_label: __address__
 
        #replacement: "localhost:9115"  # Blackbox exporter.
 
        replacement: "blackbox_exporter:9115"  # Blackbox exporter.
 
      - target_label: region
 
        replacement: "local"
 
 
 
 
 
  - job_name: 'blackbox http_post_2xx'
 
    metrics_path: /probe
 
    params:
 
      module: [http_post_2xx]  # Look for a HTTP 200 response.
 
    static_configs:
 
      - targets:
 
        - https://m-api.126.com/api/v1/m/coin/rank/thirty
 
        #- https://linuxchina.net
 
    relabel_configs:
 
      - source_labels: [__address__]
 
        target_label: __param_target
 
      - source_labels: [__param_target]
 
        target_label: instance
 
      - target_label: __address__
 
        #replacement: "localhost:9115"  # Blackbox exporter.
 
        #replacement: "10.3.10.124:9115"  # Blackbox exporter.
 
        replacement: "blackbox_exporter:9115"  # Blackbox exporter.
 
      - target_label: region
 
        replacement: "local"
 
  
 +
<pre>
 +
The setup command loads the Kibana dashboards. If the dashboards are already set up, omit this command.
  
 +
sudo filebeat setup
 +
sudo service filebeat start
 
</pre>
 
</pre>
官方配置eg  这个官方的放进去也是报错 老是重启 哈哈
 
https://github.com/prometheus/blackbox_exporter/blob/master/example.yml
 
 
  
blackbox exporter 配置文件解读
+
== Module status==
 
 
官方解释:https://github.com/prometheus/blackbox_exporter/blob/master/CONFIGURATION.md
 
 
 
 
 
git clone https://github.com/PagerTree/prometheus-grafana-alertmanager-example.git
 
cd "$DIRECTORY"
 
 
 
=* 进阶=
 
 
 
[https://cloud.tencent.com/developer/article/1584310 网络探测:Blackbox Exporter]
 
 
 
介绍几种应用场景  这个有空要试一下
 
 
 
 
 
 
 
[https://blog.csdn.net/u014029783/article/details/80001862?utm_medium=distribute.pc_relevant.none-task-blog-BlogCommendFromMachineLearnPai2-5.nonecase&depth_1-utm_source=distribute.pc_relevant.none-task-blog-BlogCommendFromMachineLearnPai2-5.nonecase blackbox_exporter源码阅读]
 
 
 
 
 
网络探测监控的操作还有HTTPS DNS TCP ICMP  SSH etc
 
 
<pre>
 
<pre>
监控主机存活状态
+
Module status  右边的 check data 按键  -- > Nginx logs dashboard
 
 
编辑prometheus配置文件
 
 
 
 
 
最后一行添加
 
 
 
最后一行添加
 
 
 
  - job_name: node_status
 
    metrics_path: /probe
 
    params:
 
      module: [icmp]
 
    static_configs:
 
      - targets: ['10.165.94.31']
 
        labels:
 
          instance: node_status
 
          group: 'node'
 
    relabel_configs:
 
      - source_labels: [__address__]
 
        target_label: __param_target
 
      - target_label: __address__
 
        replacement: 172.19.155.133:9115
 
 
 
注意:10.165.94.31是被监控端ip,172.19.155.133是Blackbox_exporter
 
 
 
监控主机端口存活状态
 
  - job_name: 'prometheus_port_status'
 
    metrics_path: /probe
 
    params:
 
      module: [tcp_connect]
 
    static_configs:
 
      - targets: ['172.19.155.133:8765']
 
        labels:
 
          instance: 'port_status'
 
          group: 'tcp'
 
    relabel_configs:
 
      - source_labels: [__address__]
 
        target_label: __param_target
 
      - source_labels: [__param_target]
 
        target_label: instance
 
      - target_label: __address__
 
        replacement: 172.19.155.133:9115
 
 
 
 
 
监控网站状态
 
 
 
  - job_name: web_status
 
    metrics_path: /probe
 
    params:
 
      module: [http_2xx]
 
    static_configs:
 
      - targets: ['http://www.baidu.com']
 
        labels:
 
          instance: user_status
 
          group: 'web'
 
    relabel_configs:
 
      - source_labels: [__address__]
 
        target_label: __param_target
 
      - target_label: __address__
 
        replacement: 172.19.155.133:9115
 
  
 
</pre>
 
</pre>
 +
systemctl daemon-reload
  
 +
=see also=
  
=* see also=
+
https://www.elastic.co/guide/en/beats/filebeat/current/filebeat-module-nginx.html
 
 
[configuration https://github.com/prometheus/blackbox_exporter/blob/master/CONFIGURATION.md Blackbox exporter]
 
 
 
[https://github.com/prometheus/blackbox_exporter/blob/master/example.yml Blackbox exporter configuration Exmaple]
 
 
 
https://github.com/prometheus/blackbox_exporter
 
  
https://yunlzheng.gitbook.io/prometheus-book/part-ii-prometheus-jin-jie/exporter/commonly-eporter-usage/install_blackbox_exporter
 
  
[https://blog.frognew.com/2018/02/prometheus-blackbox-exporter.html 使用Prometheus的blackbox_exporter进行网络监控]
+
[https://www.cnblogs.com/kuku0223/p/8317965.html ELK--filebeat nginx模块]
[[category:ops]] [[category:container]]
 

2021年4月27日 (二) 09:25的版本


ins and config

Download and install Filebeat



curl -L -O https://artifacts.elastic.co/downloads/beats/filebeat/filebeat-7.12.0-amd64.deb
sudo dpkg -i filebeat-7.12.0-amd64.deb

Edit the configuration

Modify /etc/filebeat/filebeat.yml to set the connection information:

output.elasticsearch:
  hosts: ["<es_url>"]
  username: "elastic"
  password: "<password>"
setup.kibana:
  host: "<kibana_url>"

Where <password> is the password of the elastic user, <es_url> is the URL of Elasticsearch, and <kibana_url> is the URL of Kibana.

Enable and configure the nginx module

sudo filebeat modules enable nginx

Modify the settings in the /etc/filebeat/modules.d/nginx.yml file.

Start Filebeat

The setup command loads the Kibana dashboards. If the dashboards are already set up, omit this command.

sudo filebeat setup
sudo service filebeat start

Module status

Module status  右边的 check data 按键  -- > Nginx logs dashboard

systemctl daemon-reload

see also

https://www.elastic.co/guide/en/beats/filebeat/current/filebeat-module-nginx.html


ELK--filebeat nginx模块