一、监控exporter安装
①、下载地址
nginx-exporter


这里是Windows下监控,选择amd64.
②、nginx-exporter配置
打开nginx的配置文件nginx.conf,启用nginx的基本状态.
	server {
        listen       8088;
        location /status {
		    stub_status;
		    allow 127.0.0.1;	
            deny all;
        }
	}③、 启动nginx
 
访问如下链接,查询状态,返回正常.
http://localhost:8088/status

④、启动nginx-exporter
nginx-prometheus-exporter --nginx.scrape-uri=http://localhost:8088/status

二、配置prometheus
①、编辑prometheus.yml文件,添加一下,nginx-exporter的监听端口是9113,可以从启动日志可以看到。

  # Nginx机器    
  - job_name: 'Nginx'
    static_configs:
    - targets: ['localhost:9113'] ②、启动prometheus服务

③、访问界面:
http://localhost:9090/targets
三、配置grafana
根据使用的Prometheus数据库选择监控模版。

①、这里11119模版

②、另外一个模版12767


遇到问题:
一些模版要求的Grafana的版本较高,而本地用Grafana是低版本不兼容,会导致Prometheus有数据,而Grafana面板无数据。选择适当的Grafana版本。
可以先确保Prometheus有数据。























