nginx exporter 安装配置
- 二进制安装
1
2
|
wget https://github.com/nginxinc/nginx-prometheus-exporter/releases/download/v0.10.0/nginx-prometheus-exporter_0.10.0_linux_amd64.tar.gz
tar -zxvf nginx-prometheus-exporter_0.10.0_linux_amd64.tar.gz -C ./nginx-exporter
|
- 在 nginx 上配置
1
2
3
4
5
|
./configure \
… \
--with-http_stub_status_module
make
sudo make install
|
在 nginx.config 上配置
1
2
3
4
5
6
7
|
server {
# 新增
location /nginx_status {
stub_status on;
access_log off;
}
}
|
重启 nginx 服务
1
2
|
nginx -t
nginx -s reload
|
- 启动 nginx exporter
1
|
nginx-prometheus-exporter -nginx.scrape-uri http://<nginx>:8080/nginx_status
|
- 配置 prometheus
添加 prometheus.yml
1
2
3
4
|
- job_name: "nginx-exporter"
file_sd_configs:
- files:
- "./file_sd/nginx-exporter.yaml"
|
在 ./file_sd/新建 nginx-exporter.yaml
1
2
3
|
- targets: ["<IP>:9113"]
labels:
instance: <nginx名称>
|