nginx
location /status {
stub_status;
access_log off;
allow 127.0.0.1;
allow 192.168.1.0/24;
deny all;
}
启动
wget -c https://github.com/nginxinc/nginx-prometheus-exporter/releases/download/v0.10.0/nginx-prometheus-exporter_0.10.0_linux_amd64.tar.gz
mkdir -p /usr/local/nginx_prometheus_exporter
tar -xf nginx-prometheus-exporter_0.10.0_linux_amd64.tar.gz -C /usr/local/nginx_prometheus_exporter/
cd /usr/local/nginx_prometheus_exporter/
nohup ./nginx-prometheus-exporter -nginx.scrape-uri http://test.well.otoyix.com/status &
配置
prometheus.yml 增加一段
- job_name: "nginx_status"
file_sd_configs:
- files:
- targets/nginx-*.yaml
refresh_interval: 2m
cat targets/nginx-all.yaml
- targets:
- 192.168.1.52:9113
- 192.168.1.96:9113
labels:
app: nginx_prometheus_exporter
job: nginx_status
注:
metric
nginx_connections_active | 当前客户端连接数 |
---|---|
nginx_connections_accepted | 接受的客户端连接的总数 |
nginx_connections_handled | handled状态的连接数 |
nginx_connections_reading | -读取客户端请求的连接数- |
nginx_http_requests_total | 客户端请求数 |
nginx_connections_writing | 回写客户端的连接数 |
nginx_up | 是否启动 |
nginx_connections_waiting | 等待中的连接数 |
这里只监控,不告警,告警请见之前文档
------------------end