一.下载
nginx:
链接:https://pan.baidu.com/s/1OBI1NmiMKhtLG4lYxKJyWg
提取码:2shu
nginx-module-vts-master:
链接:https://pan.baidu.com/s/1gOdYjNwHk9eEfIKcVdrE4A
提取码:m0z9
nginx-vts-exporter
链接:https://pan.baidu.com/s/1Q5E1E6Z6FSn8fTP43xBIUA
提取码:bez4
nginx-vts-stats_rev2 (1)(nginx模板)
链接:https://pan.baidu.com/s/1VUZwgEMtBOyw3sSE-qEIkA
提取码:pl9v
二.安装nginx与nginx-vts-exporter
这里nginx是重新安装
解压nginx-vts-exporter 这里放在usr/local
unzip nginx-module-vts-master.zip
解压nginx 这里放在usr/local 这里注意nginx版本有要求否则会报错 以下是nginx对应的版本
1. 解压 2. tar -zxvf nginx-1.14.2.tar.gz
把nginx-vts-exporter放到nginx路径
1. cd usr/local/nginx-1.14.2 2. ./configure --prefix=/usr/local/nginx --add-module=usr/local/nginx-module-vts-master/ 3. 注意:注意prefix=/usr/local/nginx意思是安装位置为/usr/local/nginx文件夹 4. make install
修改conf文件
http { vhost_traffic_status_zone; vhost_traffic_status_filter_by_host on; ... server { ... location /status { vhost_traffic_status_display; vhost_traffic_status_display_format html; } }
启动
1. cd /usr/local/nginx/sbin 2. ./nginx
访问http://ip/status出现以下显示则安装成功
三.安装nginx-vts-exporter-0.9.1.linux-amd64.tar
这里安装包放在usr/local下
解压
tar -zxvf nginx-vts-exporter-0.9.1.linux-amd64.tar
启动
1. cd /usr/local/nginx-vts-exporter-0.9.1.linux-amd64 2. nohup ./nginx-vts-exporter -nginx.scrape_uri http://ip/status/format/json &
输入http://ip:9913/metrics 如果出现以下证明完成
四.配置Prometheus
修改/usr/local/prometheus-2.17.1.linux-amd64/prometheus.yml
# my global config global: scrape_interval: 15s # Set the scrape interval to every 15 seconds. Default is every 1 minute. evaluation_interval: 15s # Evaluate rules every 15 seconds. The default is every 1 minute. # scrape_timeout is set to the global default (10s). # Alertmanager configuration alerting: alertmanagers: - static_configs: - targets: # - alertmanager:9093 # Load rules once and periodically evaluate them according to the global 'evaluation_interval'. rule_files: # - "first_rules.yml" # - "second_rules.yml" # A scrape configuration containing exactly one endpoint to scrape: # Here it's Prometheus itself. scrape_configs: # The job name is added as a label `job=<job_name>` to any timeseries scraped from this config. - job_name: 'prometheus' static_configs: - targets: ['localhost:9090'] - job_name: 'nginx' static_configs: - targets: ['ip:9913']
出现以下配置成功
五.配置Grafana
配置数据源 也就是prometheus地址 ip:9090
然后配置可视化界面模板
选择模板导入上文的配置
出现以下显示则表示成功