xampp 做网站,如何做解析网站,网站后台登陆代码,oppo应用商店下载1. 前言
工作中需要监控 Nginx 的指标#xff0c;选用的指标采集器是 Categraf#xff0c;特此记录下#xff0c;以备后用。
此文档并未详细记录详细的操作细节#xff0c;只记录了大概的操作步骤#xff0c;仅供参考。
2. 采集基础指标
2.1. 暴露 Nginx 自带的指标采…1. 前言
工作中需要监控 Nginx 的指标选用的指标采集器是 Categraf特此记录下以备后用。
此文档并未详细记录详细的操作细节只记录了大概的操作步骤仅供参考。
2. 采集基础指标
2.1. 暴露 Nginx 自带的指标采集接口
参考 从源码安装 Nginx 文档得知需要在源码安装时添加配置选项才能暴露指标采集接口
--with-http_stub_status_moduleenables building the ngx_http_stub_status_module module that provides access to basic status information. This module is not built by default.下载 Nginx 源码 后自行加上编译选项编译。
参考 Nginx 指标接口路由配置 在配置文件nginx.conf中的对应位置加上指标接口路由配置
location /basic_status {stub_status;
}省略已有的部分配置在http.server下添加指标接口路由配置如下所示
http {server {location /basic_status {stub_status;}}
}启动 Nginx 服务访问对应的指标页面 http://xxx/basic_status就能看到 Nginx 服务的一些基础指标
Active connections: 1
server accepts handled requests122 122 6581
Reading: 0 Writing: 1 Waiting: 02.2. 使用 Categraf 采集 Nginx 基础指标
在 Categraf 探针配置文件 conf/input.nginx/nginx.toml 中加上 Nginx 指标接口 http://xxx/basic_status上报到 prometheus从 prometheus 页面就能查到对应的指标数据了 不过这都是些很基础的指标数据我们期望能获取更丰富的指标数据。
3. 采集更丰富的指标
在网上搜索了下发现为了能采集更丰富的 Nginx 指标还得借助 nginx-module-vts 模块。
参考 操作文档 将 nginx-module-vts 模块编译进 Nginx 可执行文件中重启 Nginx 服务访问 http://xxx/status就能看到更为丰富的 Nginx 指标数据了 3.1. 使用 Categraf 采集 Nginx vts 指标
Nginx vts 指标路径不能直接配置到 conf/input.nginx/nginx.toml 文件中会报错查看 Categraf 源码发现需要配置到 prometheus 采集插件配置中 将采集 prometheus 格式数据的路径 http://xxx/status/format/prometheus 配置到 conf/input.prometheus/prometheus.toml 文件中后重启 Categraf从 prometheus 页面就能查到对应的指标数据了