首页 > 其他分享 >Kubernetes 之 Prometheus 监控 blackbox_exporter

Kubernetes 之 Prometheus 监控 blackbox_exporter

时间:2023-04-28 14:57:23浏览次数:41  
标签:__ exporter blackbox target prometheus Prometheus root

 

 

下载地址:https://prometheus.io/download/#blackbox_exporter

#blackbox_exporter 是 Prometheus 官方提供的一个exporter,可以监控 HTTP、HTTPS,、DNS、 TCP 、ICMP 等目标实例,
#从而实现对被监控节点进行监控和数据采集。

#HTTP/HTPPS: URL/API可用性检测
#TCP: 端口监听检测
#ICMP: 主机存活检测
#DNS: 域名解析

#1、下载blackbox_exporter、部署
wget https://github.com/prometheus/blackbox_exporter/releases/download/v0.23.0/blackbox_exporter-0.23.0.linux-amd64.tar.gz
[root@xksnode2 prometheus]# tar zxvf blackbox_exporter-0.23.0.linux-amd64.tar.gz
[root@xksnode2 blackbox_exporter-0.23.0.linux-amd64]# cp blackbox_exporter /usr/local/bin/
[root@xksnode2 blackbox_exporter-0.23.0.linux-amd64]# vim /etc/systemd/system/blackbox-exporter.service
[Unit]
Description=Prometheus Blackbox Exporter
After=network.target

[Service]
Type=simple
User=root
Group=root
ExecStart=/usr/local/bin/blackbox_exporter \
                --config.file=/root/prometheus/blackbox_exporter/blackbox.yml \
                --web.listen-address=:9115
Restart=on-failure

[Install]
WantedBy=multi-user.target

[root@xksnode2 blackbox_exporter]# systemctl restart blackbox-exporter.service
[root@xksnode2 blackbox_exporter]# systemctl status blackbox-exporter.service
[root@xksnode2 blackbox_exporter]# systemctl enalbe blackbox-exporter.service


[root@xksnode2 blackbox_exporter]# netstat -nltp | grep 9115
tcp6       0      0 :::9115                 :::*                    LISTEN      29722/blackbox_expoerter

#2、测试访问
http://192.168.19.182:9115/

#3、实现URL监控
#prometheus 调用 blackbox exporter 实现对 URL/ICMP 的监控

 - job_name: 'http_status'
    metrics_path: /probe
    params:
      module: [http_2xx]
    static_configs:
      - targets: ['http://www.xiaomi.com', 'http://www.magedu.com']
        labels:
          instance: http_status
          group: web
    relabel_configs:
      - source_labels: [__address__] #将__address__(当前监控目标URL地址的标签)修改为__param_target,用于传递给blackbox_exporter
        target_label: __param_target #标签key为__param_target、value为www.xiaomi.com。key为__param_target、value为www.magedu.com
      - source_labels: [__param_target] #基于__param_target获取监控目标
        target_label: url #将监控目标的值与url创建一个label
      - target_label: __address__  #新添加一个目标__address__,指向blackbox_exporter服务器地址,用于将监控请求发送给指定的blackbox_exporter服务器
        replacement: 192.168.19.182:9115 #指定blackbox_exporter服务器地址
 
#4、实现ICMP监控
[root@xksmaster1 yaml]# cat /apps/prometheus/prometheus.yml
# icmp 检测
  - job_name: 'ping_status'
    metrics_path: /probe
    params:
      module: [icmp]
    static_configs:
      - targets: ['172.31.0.2',"223.6.6.6","192.168.19.2"]
        labels:
          instance: 'ping_status'
          group: 'icmp'
    relabel_configs:
      - source_labels: [__address__]
        target_label: __param_target
      - source_labels: [__param_target]
        target_label: ip
      - target_label: __address__
        replacement: 192.168.19.182:9115

[root@xksmaster1 yaml]# systemctl restart prometheus

 
#5、实现端口监控
[root@xksmaster1 yaml]# cat /apps/prometheus/prometheus.yml
# 端口监控
  - job_name: 'port_status'
    metrics_path: /probe
    params:
      module: [tcp_connect]
    static_configs:
      - targets: ['192.168.19.180:9090', '192.168.19.181:3000','192.168.19.182:80']
        labels:
          instance: 'port_status'
          group: 'port'
    relabel_configs:
      - source_labels: [__address__]
        target_label: __param_target
      - source_labels: [__param_target]
        target_label: ip
      - target_label: __address__
        replacement: 192.168.19.182:9115

[root@xksmaster1 yaml]# systemctl restart prometheus

#6、Grafana导入模板-13587、9965

 

标签:__,exporter,blackbox,target,prometheus,Prometheus,root
From: https://www.cnblogs.com/birkhoffxia/p/17362174.html

相关文章

  • 二进制部署 Prometheus
    二进制部署Prometheus(1)上传软件包下载地址:https://prometheus.io/download/(2)解压软件包mkdir/softwares-pvtarxfprometheus-2.37.6.linux-amd64.tar.gz-C/softwares/(3)启动prometheusServercd/softwares/prometheus-2.37.6.linux-amd64./prometheus......
  • Prometheus+grafanaA
    一、Prometheus简介、容器监控的实现方对比虚拟机或者物理机来说比大的区别,比如容器在k8s环境中可以任意横向扩容与缩容,那么就需要监控服务能够自动对新创建的容器进行监控,当容器删除后又能够及时的从监控服务中删除,而传统的zabbix的监控方式需要在每一个容器中安装启动agent,并......
  • Prometheus监控之SNMP Exporter介绍和数据展现
    由于技术能力有限,文章仅能进行简要分析和说明,如有不对的地方,请指正,谢谢......
  • Prometheus+grafana
    一、Prometheus简介、容器监控的实现方对比虚拟机或者物理机来说比大的区别,比如容器在k8s环境中可以任意横向扩容与缩容,那么就需要监控服务能够自动对新创建的容器进行监控,当容器删除后又能够及时的从监控服务中删除,而传统的zabbix的监控方式需要在每一个容器中安装启动agent,并......
  • 容器云平台监控告警体系(五)—— Prometheus发送告警机制
    1、概述在Prometheus的架构中告警被划分为两个部分,在PrometheusServer中定义告警规则以及产生告警,Alertmanager组件则用于处理这些由Prometheus产生的告警。本文主要讲解Prometheus发送告警机制也就是在PrometheusServer中定义告警规则和产生告警部分,不过多介绍Alertmanager组......
  • Prometheus + Grafana,开源监控神器!
    1Prometheus介绍 Prometheus是一个开源系统监控和警报工具包,用于收集和聚合指标作为时间序列数据,即将指标信息、记录的时间戳以及称为标签的可选键值对一起存储,详细介绍请查看官方文档 2Prometheus及其组件安装因Prometheus组件基本都是用Go编写的,所以更易于构建和部署,解压......
  • Prometheus 四大度量指标的了解和应用
    Prometheus四大度量指标的了解和应用什么是度量指标Prometheus的指标格式对外提供metrics服务Prometheus四大度量指标的了解和应用Counter(计数器)实战演练Gauge(仪表盘)实战演练Histogram(累积直方图)实战演练Summary(摘要)实战演练小结Prometh......
  • Linux 安装 Node Exporter
    1.下载安装cdsrcwgethttps://github.com/prometheus/node_exporter/releases/download/v1.5.0/node_exporter-1.5.0.linux-amd64.tar.gztarxfnode_exporter-1.5.0.linux-amd64.tar.gzmvnode_exporter-1.5.0.linux-amd64/node_exporter/usr/binuseradd-s/sbin/nologin......
  • prometheus node-exporter安装
    目录prometheusnode-exporter安装包安装在linux服务器Daemonset安装Docker安装helm安装prometheusnode-exporter安装安装有很多中方法包安装在linux服务器NodeExporter是一个用于收集Linux系统信息并暴露为Prometheus格式的指标的守护进程。要启动NodeExporter,可以......
  • k8s下prometheus启动node_exporter
    启动访问地址:IP:9090启动方式:./prometheus--web.enable-lifecycle:热更新,不用重启即生效加载方法有以下两种#1.kill-HUPpid#2.curl-XPOSThttp://IP/-/reload--storage.tsdb.path:数据存储位置,默认是data目录。--storage.tsdb.retention.time:保留时间,默认是15天,过15天之后,就删......