当前位置: 首页 > news >正文

prometheus+grafana接入nginx实战

接上文:
prometheus监控实战
Grafana接入Prometheus实战
操作系统:阿里龙蜥操作系统(AnolisOS-7.9-GA-x86_64)(类似CentOS7.9)

1.安装nginx

nginx下载地址:https://nginx.org/download/nginx-1.28.0.tar.gz
nginx-module-vts下载地址:https://codeload.github.com/vozlt/nginx-module-vts/tar.gz/refs/tags/v0.2.4

本文默认放在“/home”目录下,如下图:
在这里插入图片描述

cd /home/nginx_home/nginx-1.28.0# 执行配置文件
./configure --prefix=/usr/local/nginx --with-http_stub_status_module --add-module=/home/nginx_home/nginx-module-vts-0.2.4# 执行make命令
make
make install# 查看Nginx是否存在
whereis nginx
# 查看版本
/usr/local/nginx/sbin/nginx -v

在这里插入图片描述
修改配置文件:
在这里插入图片描述
检查配置:

cd /usr/local/nginx/conf
/usr/local/nginx/sbin/nginx -t

启动:

cd /usr/local/nginx/sbin
./nginx

查看进程:

 netstat -lntp | grep 80

访问统计信息:
http://ip/status
http://10.86.97.201/status
在这里插入图片描述

2.安装nginx-vts-exporter

下载地址:https://github.com/sysulq/nginx-vts-exporter/releases
在这里插入图片描述

# 解压
tar -xvf nginx-vts-exporter-0.10.3.linux-amd64.tar.gz# 启动
cd /home/nginx_home/nginx-vts-exporter-0.10.3
nohup /home/nginx_home/nginx-vts-exporter-0.10.3/nginx-vts-exporter -nginx.scrape_uri http://10.86.97.201/status/format/json &# 检查
lsof -i:9913

访问:
http://10.86.97.201:9913/metrics
在这里插入图片描述

3.接入prometheus

修改配置:

vim /home/prometheus/prometheus.yml- job_name: "nginx-vts"metrics_path: "/metrics"static_configs:- targets: ["10.86.97.201:9913"]

重启prometheus:

lsof -i:9090
kill -9 pid
nohup /home/prometheus/prometheus --config.file="/home/prometheus/prometheus.yml" &

访问:http://10.86.97.200:9090
在这里插入图片描述

4.接入grafana

访问grafana:
http://10.86.97.200:3000/
Grafana Dashboard ID: 2949
在这里插入图片描述

5.常见问题

①问题:nginx安装,执行./configure报错如下:
./configure: error: C compiler cc is not found

解决:
sudo yum groupinstall “Development Tools”

②问题:nginx安装,执行./configure,报错如下:
./configure: error: the HTTP rewrite module requires the PCRE library.
You can either disable the module by using --without-http_rewrite_module
option, or install the PCRE library into the system, or build the PCRE library
statically from the source with nginx by using --with-pcre=option.

解决:
安装 PCRE 开发库:sudo yum install pcre-devel

③问题:nginx安装,执行./configure,报错如下:
./configure: error: the HTTP gzip module requires the zlib library.
You can either disable the module by using --without-http_gzip_module
option, or install the zlib library into the system, or build the zlib library
statically from the source with nginx by using --with-zlib=option.

解决:
sudo yum install zlib-devel

④问题:nginx-vtx-exporter启动,报错如下:
./nginx-vtx-exporter: /lib64/libc.so.6: version `GLIBC_2.32’ not found (required by ./nginx-vtx-exporter)

解决:
不要使用最新版本,建议使用nginx-vts-exporter-0.10.3.linux-amd64.tar.gz。

6.相关资源

官网下载较慢,相关资源已上传百度网盘(虽然限速,也比官网快):链接: https://pan.baidu.com/s/1MkLygpBzD-OBxxUh_w6HUw?pwd=h22b

http://www.dtcms.com/a/272276.html

相关文章:

  • 零成本实现商品图换背景
  • 静态路由实验(2)
  • Vue3 深度解析:渲染器与渲染函数的奥秘
  • 【PTA数据结构 | C语言版】链式栈的3个操作
  • linux 4.14 kernel屏蔽arm arch timer的方法
  • 网络编程与自动化
  • 高亚科技签约奕源金属,助力打造高效智能化采购管理体系
  • Flask 入门教程:用 Python 快速搭建你的第一个 Web 应用
  • 在 Ubuntu 上安装和配置 Kafka
  • 下一代防火墙-终端安全防护
  • 普林斯顿大学DPPO机器人学习突破:Diffusion Policy Policy Optimization 全新优化扩散策略
  • Eigen 几何模块深拆:Isometry3d vs Affine3d + 变换矩阵本质详解
  • OSPF协议:核心概念与配置要点解析
  • 虚拟项目[3D物体测量]
  • 从真人到数字分身:3D人脸扫描设备在高校数字人建模教学中的应用
  • 强化学习 MDP
  • Selenium 4 教程:自动化 WebDriver 管理与 Cookie 提取 || 用于解决chromedriver版本不匹配问题
  • 《PyQt6-3D:开启Python 3D开发新世界》
  • Windows Edge 播放 H.265 视频指南
  • OpenAI正准备推出一款搭载人工智能功能的网络浏览器,试图直接挑战Alphabet旗下
  • 前端面试专栏-算法篇:21. 链表、栈、队列的实现与应用
  • NAT技术(网络地址转换)
  • 【实战】使用 ELK 搭建 Spring Boot Docker 容器日志监控系统
  • OSPF实验以及核心原理全解
  • 【SkyWalking】配置告警规则并通过 Webhook 推送钉钉通知
  • HP EVA SAN 数据恢复利器:Data recovery plugin for HP StorageWorks EVA
  • 前端项目集成husky + lint-staged + commitlint
  • Web-Bench:基于web标准和框架的benchmark
  • Fiddler中文版全面评测:功能亮点、使用场景与中文网资源整合指南
  • 什么是强化学习(RL)--2