• Prometheus apache_exporter 监控配置


    Prometheus apache_exporter 监控配置

    在安装apache_exporter之前,首先得保证Apache有mod_status这个模块

    #修改Apache的配置文件:httpd-info.conf
    vim /usr/local/apache/conf/extra/httpd-info.conf
    <Location /server-status>
      SetHandler server-status
      Order deny,allow
      allow from all
      AuthType Basic
      AuthName 'Apache Server Status'
      AuthUserFile '/usr/local/apache/conf/.htpasswd'
      Require valid-user
    </Location>

    <Location /server-info>
      SetHandler server-status
      Order deny,allow
      allow from all
      AuthType Basic
      AuthName 'Apache Server Status'
      AuthUserFile '/usr/local/apache/conf/.htpasswd'
      Require valid-user
    </Location>
    • 由于Apache服务信息属于敏感信息,需配置用户身份证

      htpasswd -c -m /usr/local/apache/conf/.htpasswd hdkj

    • 接下来正式安装apache_exporter

    • 创建一个临时目录

    • $ mkdir /tmp/go

    • 设置环境变量

    • $ export GOPATH=/tmp/go

    • 进入临时目录使用go命令从远程仓库获取apache_exporter

    • $ cd /tmp/go

    • $ go get -u github.com/Lusitaniae/apache_exporter

    • 查看一下下载好的apache_exporter

    • ll src/github.com/Lusitaniae/apache_exporter/

    • 使用make命令编译源代码

    • 编译完成之后,将生成的apache_exporter拷贝至安装目录

    配置启动服务:

    • vim /usr/lib/systemd/system/apache_exporter.service

      [Unit]
      Description=Prometheus apache exporter
      Documentation=https://github.com/Lusitaniae/apache_exporter
      After=network.target

      [Service]

      Type=simple

      ExecStart=/usr/local/apache_exporter/apache_exporter --scrape_uri=http://hdkj:HDkj123456@localhost/server-status?auto
      Restart=on-failure

      [Install]
      WantedBy=multi-user.target

       

    • 启动一下服务

    • systemctl start apache_exporter

    • ss -tnl | grep 9117 #如果端口9117存在,说明服务启动成功;

    在Promethus配置文件中加入apache_exporter

    job_name: 'apache_exporter'
    metrics_path: "/metrics"
    static_configs:

    - targets: ['192.168.8.133:9117']
    labels:
      instance: '192.168.8.133:9117'

    - targets: ['192.168.8.134:9117']
    labels:
      instance: '192.168.8.134:9117'

     

    配置监控规则:

    groups:

    - name: apache_exporter_alerts
    rules:
       - alert: ApacheWorkerStatus
        expr: apache_workers{state="busy"} > 320
         for: 30s
        labels:
          severity: warning
        annotations:
          summary: "ApacheWorkerStatus (instance {{ $labels.instance }})"
          description: "Apache worker status is busy more than 80% VALUE = {{ $value }} LABELS: {{ $labels }}"

       - alert: ApacheConnectionsStatus
        expr: apache_connections{state="total"} > 1000
         for: 30s
        labels:
          severity: warning
        annotations:
          summary: "Apache Connection Statuses (instance {{ $labels.instance }})"
          description: "Apache Connections Is Too many VALUE = {{ $value }} LABELS: {{ $labels }}"

       - alert: Apache Service
        expr: apache_up == 0
         for: 30s
        labels:
          severity: error
        annotations:
          summary: "ApacheServiceStatuses (instance {{ $labels.instance }})"
          description: "Apache Service Is Not Work;Please Connect Ops Group Quick Deal With VALUE = {{ $value }} LABELS: {{ $labels }}"

     

     

     

  • 相关阅读:
    delphi xe10 FMX 启动参数
    delphi xe6 JSON 测试
    oracle实现http请求,oracle发送http请求。
    ORACLE存储过程调用Web Service
    新搭建的iis服务器,运行网站报 System.BadImageFormatException:未能加载文件或程序集”....“或它的某一个依赖项。
    c#的http请求工具类核心代码
    vue-cli3 取消关闭eslint 校验代码
    quartz.net数据库持久化教程
    sql备份一张表的数据
    iis 长期无访问导致定时任务不执行的解决方案
  • 原文地址:https://www.cnblogs.com/tanghu/p/12617803.html
Copyright © 2020-2023  润新知