安装 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 模板