五分钟带你玩转prometheus(六)监控nginx

本文涉及的产品
可观测监控 Prometheus 版,每月50GB免费额度
简介: 五分钟带你玩转prometheus(六)监控nginx


一.下载

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对应的版本

image.png

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出现以下显示则安装成功

image.png

三.安装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 如果出现以下证明完成

image.png

四.配置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']    

出现以下配置成功

image.png

五.配置Grafana

配置数据源 也就是prometheus地址 ip:9090

image.png

image.png

然后配置可视化界面模板

image.png

选择模板导入上文的配置

image.png

image.png

出现以下显示则表示成功

image.png


相关实践学习
容器服务Serverless版ACK Serverless 快速入门:在线魔方应用部署和监控
通过本实验,您将了解到容器服务Serverless版ACK Serverless 的基本产品能力,即可以实现快速部署一个在线魔方应用,并借助阿里云容器服务成熟的产品生态,实现在线应用的企业级监控,提升应用稳定性。
相关文章
|
9月前
|
Prometheus 监控 Cloud Native
Prometheus实战篇:Prometheus监控nginx
在此专栏的前几篇文章中已经准备了一台服务器作为我们进行环境的准备.大家也可以通过虚拟机创建俩台服务器,一台作为Prometheus的安装另外一台进行其他软件安装并且进行监控的服务器.
|
存储 Prometheus 监控
统一观测丨使用 Prometheus 监控 Nginx Ingress 网关最佳实践
统一观测丨使用 Prometheus 监控 Nginx Ingress 网关最佳实践
统一观测丨使用 Prometheus 监控 Nginx Ingress 网关最佳实践
|
Prometheus 监控 Cloud Native
|
Prometheus 监控 Cloud Native
prometheus+grafana监控nginx
prometheus+grafana监控nginx
762 0
prometheus+grafana监控nginx
|
监控 应用服务中间件 nginx
Prometheus 监控整合 Nginx Metrics
Prometheus 监控整合 Nginx Metrics
8524 0
|
3月前
|
缓存 应用服务中间件 网络安全
Nginx中配置HTTP2协议的方法
Nginx中配置HTTP2协议的方法
245 7
|
4月前
|
应用服务中间件 BI nginx
Nginx的location配置详解
【10月更文挑战第16天】Nginx的location配置详解
|
1月前
|
存储 应用服务中间件 Linux
nginx配置证书和私钥进行SSL通信验证
nginx配置证书和私钥进行SSL通信验证
69 4
|
3月前
|
负载均衡 监控 应用服务中间件
配置Nginx反向代理时如何指定后端服务器的权重?
配置Nginx反向代理时如何指定后端服务器的权重?
240 61
|
3月前
|
安全 应用服务中间件 网络安全
如何测试Nginx反向代理实现SSL加密访问的配置是否正确?
如何测试Nginx反向代理实现SSL加密访问的配置是否正确?
253 60