Prometheus(五)—— 监控 apache 服务

安装 Apache

[root@pre1 ~]#  yum -y install httpd

安装 Apache exporter 收集 apache的 json 数据

[root@localhost 桌面]# wget https://github.com/Lusitaniae/apache_exporter/releases/download/v0.5.0/apache_exporter-0.5.0.linux-amd64.tar.gz
# 解压
[root@pre1 ~]# tar zxf apache_exporter-0.5.0.linux-amd64.tar.gz 
[root@pre1 ~]# mv apache_exporter-0.5.0.linux-amd64 /usr/local/apache_exporter
[root@pre1 ~]# cd /usr/local/apache_exporter
[root@pre1 apache_exporter]# ls
apache_exporter  LICENSE
# 移动位置
[root@pre1 apache_exporter]# cp apache_exporter  /usr/local/bin/

启动 apahce 服务

[root@pre1 apache_exporter]# netstat -antuple | grep 80
tcp        0      0 0.0.0.0:80              0.0.0.0:*               LISTEN      0          25334      2009/nginx: master  
#关闭上篇实验的nginx
[root@pre1 apache_exporter]# nginx -s stop
[root@pre1 apache_exporter]# netstat -antuple | grep 80
[root@pre1 apache_exporter]# systemctl start httpd
[root@pre1 apache_exporter]# netstat -antuple | grep 80
tcp6       0      0 :::80                   :::*                    LISTEN      0          29694      4806/httpd       

启动 apache_exporter
[

root@pre1 apache_exporter]# apache_exporter 
INFO[0000] Starting apache_exporter (version=0.5.0, branch=HEAD, revision=f6a5b4814ea795ee9eac745c55649cce9e5117a9)  source="apache_exporter.go:305"
INFO[0000] Build context (go=go1.9.2, user=root@0fdc4d8924f5, date=20171113-21:19:13)  source="apache_exporter.go:306"
INFO[0000] Starting Server: :9117                        source="apache_exporter.go:307"

[root@pre1 nginx-vts-exporter]# netstat -antuple | grep 9117
tcp6       0      0 :::9117                 :::*                    LISTEN      0          29849      4814/apache_exporte 

添加监控至 Prometheus

[root@pre1 nginx-vts-exporter]# vim /usr/local/prometheus/conf/prometheus.yml
[root@pre1 nginx-vts-exporter]# systemctl restart prometheus

- job_name: 'apache_status'
    static_configs:
    - targets: ['192.168.122.101:9117']

报错:无法收集到页面信息
在这里插入图片描述
添加 apache 模板

[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>

在这里插入图片描述
访问测试数据页面
在这里插入图片描述

再次启动

[root@pre1 apache_exporter]# systemctl restart httpd
[root@pre1 apache_exporter]# apache_exporter 
INFO[0000] Starting apache_exporter (version=0.5.0, branch=HEAD, revision=f6a5b4814ea795ee9eac745c55649cce9e5117a9)  source="apache_exporter.go:305"
INFO[0000] Build context (go=go1.9.2, user=root@0fdc4d8924f5, date=20171113-21:19:13)  source="apache_exporter.go:306"
INFO[0000] Starting Server: :9117                        source="apache_exporter.go:307"

导入 Grafana 模板

在这里插入图片描述

在这里插入图片描述
在这里插入图片描述

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 2
    评论
Prometheus可以用于监控Apache服务器。要监控Apache,你需要完成以下几个步骤: 1. 首先,你需要在Prometheus的配置文件(prometheus.yml)中添加一个job,指定Apache服务器的地址和端口。在该文件中找到`scrape_configs`部分,添加以下内容: ``` - job_name: 'apache_status' static_configs: - targets: ['<Apache服务器的IP地址>:<Apache服务器的端口号>'] ``` 请注意替换`<Apache服务器的IP地址>`和`<Apache服务器的端口号>`为你的Apache服务器的实际地址和端口。 2. 保存并关闭配置文件后,重启Prometheus服务,以使更改生效。 3. 现在,Prometheus将开始监控Apache服务器上的指定地址和端口。你可以在Prometheus的Web界面上查看指标数据。 请注意,Apache服务器必须提供可供Prometheus抓取的指标数据。你可以使用一些工具,如nginx-vts-exporter或自定义的Exporter,来公开Apache服务器的指标数据。具体的实现细节因使用的工具而异。 希望这个回答对你有帮助!123 #### 引用[.reference_title] - *1* *3* [使用Prometheus和Grafana监控Apache Doris](https://blog.csdn.net/yy8623977/article/details/126223999)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v92^chatsearchT3_1"}} ] [.reference_item] - *2* [Prometheus)—— 监控 apache 服务](https://blog.csdn.net/qq_44658961/article/details/109671435)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v92^chatsearchT3_1"}} ] [.reference_item] [ .reference_list ]
评论 2
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值