暂无图片
暂无图片
暂无图片
暂无图片
暂无图片

技术干货|使用Prometheus+Grafana监控apache实例详解

西安川石 2022-12-29
1027



GUIDE

导读


前面推文中我们分享了Prometheus和Grafana部署及操作知识,现在我们要开始学会利用普罗米修斯+Grafana搭建监控系统.今天给大家分享使用Prometheus+Grafana监控apache实例.落下了之前内容的伙伴可以在文末查阅往期内容,也可以加小编微信领取同步课件!

01

下载apache_exporter

    GitHub - Lusitaniae/apache_exporter: Prometheus exporter for Apache
    复制

    02

    解压并启动apache_exporter

      # 解压
      [root@pre1 ~]# tar xzvf apache_exporter-0.11.0.linux-386.tar.gz
      [root@pre1 ~]# mv apache_exporter-0.11.0.linux-386 apache_exporter
      #启动apache-exporter
      apache-exporter启动时的参数包括以下几个部分:
      -h, --help Show context-sensitive help (also try --help-long and
      --help-man).
      --telemetry.address=":9117"
      Address on which to expose metrics.
      --telemetry.endpoint="/metrics"
      Path under which to expose metrics.
      --scrape_uri="http://localhost/server-status/?auto"
      URI to apache stub status page.
      --host_override="" Override for HTTP Host header; empty string for no
      override.
      --insecure Ignore server certificate if using https.
      --web.config="" Path to config yaml file that can enable TLS or
      authentication.
      --log.level=info Only log messages with the given severity or above.
      One of: [debug, info, warn, error]
      --log.format=logfmt Output format of log messages. One of: [logfmt, json]
      --version Show application version.
      [root@localhost software]# ./apache_exporter --
      scrape_uri="http://192.168.3.73/server-status?auto" &
      #需要注意的是这里一定要使用scrape_uri来指定需要监控的URI地址,否则默认监控的为
      localhost/server-auto,这样prometheus就无法读取到这台服务器的监控数据
      复制

      03

      启动apache服务器并添加监控status

      Linux启动httpd命令:
      Linux httpd命令是Apache HTTP服务器程序。httpd为Apache HTTP服务器程序。直接执行程序可启动服务器的服务。
      1、apahce启动命令:
      /usr/local/apache2/bin/apachectl start
      2、apache停止命令:
      /usr/local/apache2/bin/apachectl stop
      如果apache安装成为linux的服务的话,可以用以下命令操作:
      service httpd start 启动
      service httpd restart 重新启动
      service httpd stop 停止服务
        [root@pre1 apache_exporter]# vim /etc/httpd/conf/httpd.conf
        354 LoadModule status_module modules/mod_status.so
        355 <location /server-status>
        356 SetHandler server-status
        357 Order Deny,Allow
        358 Deny from nothing
        359 Allow from all
        360 </location>
        在配置文件httpd.conf中添加以下监控配置
        复制

        04

        修改prometheus配置文件

          - job_name: 'apache_status'
          static_configs:
          - targets: ['apache服务器IP:9117']
          复制
          修改配置文件后,重启prometheus容器

          05

          在grafana导入模板

          在grafana中导入3894模板

          往/期/回/顾



          Prometheus(普罗米修斯)核心组件


          Prometheus(普罗米修斯)自定义查询语言PromQL


          Prometheus(普罗米修斯)之PromQL完全解释


          Prometheus(普罗米修斯)PromQL查询语言之操作符


          PromQL查询语言之聚合操作&内置函数


          Prometheus 在HTTP API中使用PromQL


          Prometheus监控4个黄金指标和USE方法


          Prometheus告警及告警规则


          Prometheus部署Alertmanager


          Prometheus之Alertmanager路由配置


          Prometheus定义告警模板&告警通知&性能优化


          Prometheus之Console Template创建可视化监控平台实例


          Grafana及Graph面板全解释


          Grafana分布统计Heatmap面板全解释


          Grafana当前状态SingleStat面板全解释


          Grafana模板化Dashboard设计实例教程


          Docker容器下部署Alertmanager集群监控


          Docker容器下部署Alertmanager集群监控


          使用Prometheus+Grafana监控MySQL实例详解


          使用Prometheus+Grafana监控Tomcat实例详解


          使用Prometheus+Grafana监控nginx实例详解

          -End-

          「有用就扩散」

          「有用就点在看」

          更多课程咨询或免费资料领取,扫下方二维码即可!

          文章转载自西安川石,如果涉嫌侵权,请发送邮件至:contact@modb.pro进行举报,并提供相关证据,一经查实,墨天轮将立刻删除相关内容。

          评论