• Prometheus+blackbox_exporter


    Blackbox_exporter 主动监测主机与服务状态

    Prometheus 官方提供的 exporter 之一,可以提供 http、dns、tcp、icmp 的监控数据采集

    下载地址

    这里要选择自己合适的版本

    下载并解压

    wget https://github.com/prometheus/blackbox_exporter/releases/download/v0.18.0/blackbox_exporter-0.18.0.linux-amd64.tar.gz
    tar -zxvf blackbox_exporter-0.18.0.linux-amd64.tar.gz
    

    ARM

    wget https://github.com/prometheus/blackbox_exporter/releases/download/v0.18.0/blackbox_exporter-0.18.0.linux-arm64.tar.gz
    tar -zxvf blackbox_exporter-0.18.0.linux-arm64.tar.gz
    

    配置启动文件

    vim /etc/systemd/system/blackbox_exporter.service
    
    [Unit]
    Description=Prometheus Monitoring System
    Documentation=Prometheus Monitoring System
    
    [Service]
    ExecStart=/opt/monitor/service/blackbox_exporter-0.18.0.linux-arm64/blackbox_exporter 
         --config.file=/opt/monitor/service/blackbox_exporter-0.18.0.linux-arm64/blackbox.yml
    
    [Install]
    WantedBy=multi-user.target
    

    刷新文件

    systemctl daemon-reload
    

    启动命令

    systemctl start blackbox_exporter    #启动
    systemctl stop blackbox_exporter     #停止
    systemctl restart blackbox_exporter  #重启
    systemctl status blackbox_exporter   #查看状态
    

    修改promethues配置文件

    进入promethues文件夹

    cd prometheus-2.22.1.linux-arm64/
    vim prometheus.yml
    
    static_configs:
          - targets: ['192.168.*.*:1111']
            labels:
              hostname: '服务器名称'
              group: 'tcp'
              service: '服务名称'
    
    
        relabel_configs:
          - source_labels: [__address__]
            target_label: __param_target
          - source_labels: [__param_target]
            target_label: ip
            regex: "(.*):(.*)"
            replacement: $1
          - source_labels: [__param_target]
            target_label: port
            regex: "(.*):(.*)"
            replacement: $2
          - source_labels: []
            target_label: __address__
            replacement: localhost:9115
    

    重启Prometheus

    systemctl restart prometheus  #重启
    

    配置Grafana

    这里输入9965


  • 相关阅读:
    Apache CXF实战之四 构建RESTful Web Service
    使用CXF开发RESTFul服务
    Java多线程中的异常处理
    Checked异常和Runtime异常体系
    hql 语法与详细解释<转>
    hibernate实现有两种配置,xml配置与注释配置。<转>
    Hibernate配置详细解释
    重构(Refactoring)技巧读书笔记(General Refactoring Tips)
    Hibernate(1)——数据访问层的架构模式<转>
    关于layer.photos即照片显示的问题。
  • 原文地址:https://www.cnblogs.com/SunMoonSky/p/14007147.html
Copyright © 2020-2023  润新知