技术干货

您所在的位置:网站首页 linux386 技术干货

技术干货

2023-03-27 23:31| 来源: 网络整理| 查看: 265

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

01下载apache_exporterGitHub - 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 start2、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 356 SetHandler server-status 357 Order Deny,Allow 358 Deny from nothing 359 Allow from all 360 在配置文件httpd.conf中添加以下监控配置

04修改prometheus配置文件- job_name: 'apache_status' static_configs: - targets: ['apache服务器IP:9117']

修改配置文件后,重启prometheus容器

05在grafana导入模板

在grafana中导入3894模板



【本文地址】


今日新闻


推荐新闻


CopyRight 2018-2019 办公设备维修网 版权所有 豫ICP备15022753号-3