ngx_http_stub_status_module模块是Nginx中用来统计Nginx服务所接收和处理的请求数量,只要在编译安装Nginx的时候加上参数--with-http_stub_status_module就可以开启该功能,如果编译时没有加该参数的话可以重新编译安装一次,不会影响原有的配置文件。

#重新编译nginx
./configure --prefix=/usr/local/nginx --with-http_stub_status_module
make
make install
./nginx -V #查询版本信息
nginx version: nginx/1.11.6
built by gcc 4.4.7 20120313 (Red Hat 4.4.7-23) (GCC)
configure arguments: --prefix=/usr/local/nginx --with-http_stub_status_module
#配置nginx
vim nginx.conf
location /nginx-status {
stub_status on;
access_log off;
}

测试:

结果说明:
Active connections:正在处理的活动连接数
server accepts handled requests
第一个 server 表示Nginx启动到现在共处理了9个连接
第二个 accepts 表示Nginx启动到现在共成功创建 9 次握手
第三个 handled requests 表示总共处理了 21 次请求
请求丢失数 = 握手数 - 连接数 ,可以看出目前为止没有丢失请求
Reading: 0 Writing: 1 Waiting: 1
Reading:Nginx 读取到客户端的 Header 信息数
Writing:Nginx 返回给客户端 Header 信息数
Waiting:Nginx 已经处理完正在等候下一次请求指令的驻留链接(开启keep-alive的情况下,这个值等于
Active - (Reading+Writing))

2、部署与收集系统指标

vim metricbeat.yml

metricbeat.config.modules:
# Glob pattern for configuration loading
path: ${path.config}/modules.d/*.yml # Set to true to enable config reloading
reload.enabled: false # Period on which files under path should be checked for changes
#reload.period: 10s #==================== Elasticsearch template setting ========================== setup.template.settings:
index.number_of_shards: 2
index.codec: best_compression
#_source.enabled: false setup.kibana: output.elasticsearch:
# Array of hosts to connect to.
hosts: ["127.0.0.1:9200","127.0.0.1:9201","127.0.0.1:9202"] processors:
- add_host_metadata: ~
- add_cloud_metadata: ~

metricbeat默认会加载${path.config}/modules.d/*.yml下的modules模块来收集指标数据,默认只开启了收集system的cpu 内存等信息

system module配置: 查看system.yml的信息

# Module: system
# Docs: https://www.elastic.co/guide/en/beats/metricbeat/6.5/metricbeat-module-system.html - module: system
period: 10s
metricsets:
- cpu
#- load
- memory
- network
- process
- process_summary
#- core
#- diskio
#- socket
process.include_top_n:
by_cpu: 5 # include top 5 processes by CPU
by_memory: 5 # include top 5 processes by memory - module: system
period: 1m
metricsets:
- filesystem
- fsstat
processors:
- drop_event.when.regexp:
system.filesystem.mount_point: '^/(sys|cgroup|proc|dev|etc|host|lib)($|/)' - module: system
period: 15m
metricsets:
- uptime #- module: system
# period: 5m
# metricsets:
# - raid
# raid.mount_point: '/'

现在我们要收集nginx的指标信息需要开启对nginx的配置

#启用redis module
./metricbeat modules enable nginx
#修改redis module配置
vim modules.d/nginx.yml
# Module: nginx
# Docs: https://www.elastic.co/guide/en/beats/metricbeat/6.5/metricbeat-modulenginx.html
- module: nginx
#metricsets:
# - stubstatus
period: 10s
# Nginx hosts
hosts: ["http://192.168.40.133"]
# Path to server status. Default server-status
server_status_path: "nginx-status"
#username: "user"
#password: "secret"

开启nginx之后,我们可以使用命令metricbeat modules list 查看当前启用了哪些moudles

接下来我们修改modules.d/nginx.yml

内容如下

# Module: nginx
# Docs: https://www.elastic.co/guide/en/beats/metricbeat/6.5/metricbeat-module-nginx.html - module: nginx
#metricsets:
# - stubstatus
period: 10s # Nginx hosts
hosts: ["http://127.0.0.1:8088"]
server_status_path: "nginx-status" # Path to server status. Default server-status
#server_status_path: "server-status" #username: "user"
#password: "secret"

接下来我们就可以启动metricbeat.exe收集nginx的指标了

metricbeat -e -c metricbeat.yml

2、让收集的度量信息在kibana上展示

1、第一步需要修改metricbeat.yml配置

metricbeat.config.modules:
# Glob pattern for configuration loading
path: ${path.config}/modules.d/*.yml # Set to true to enable config reloading
reload.enabled: false # Period on which files under path should be checked for changes
#reload.period: 10s #==================== Elasticsearch template setting ========================== setup.template.settings:
index.number_of_shards: 2
index.codec: best_compression
#_source.enabled: false setup.kibana:
host: "127.0.0.1:5601" output.elasticsearch:
# Array of hosts to connect to.
hosts: ["127.0.0.1:9200","127.0.0.1:9201","127.0.0.1:9202"] processors:
- add_host_metadata: ~
- add_cloud_metadata: ~

1、在这里指定kibana的地址

setup.kibana:
host: "127.0.0.1:5601"

2、文件配置好之后

#安装仪表盘到Kibana 执行命令/metricbeat setup --dashboards,这里一定要保证kibana已经处于正常的启动状态

安装成功之后我们在kibana上面就可以看到对于的仪表盘信息了

最新文章

  1. Kibana+Logstash+Elasticsearch 日志查询系统
  2. 基于Redis的爬虫平台的实现
  3. 【转】三十分钟掌握STL
  4. 第二篇:Power BI数据可视化之基于Web数据的报表制作(经典级示例)
  5. Java中普通代码块,构造代码块,静态代码块的代码演示样例及区分
  6. jQuery中on()方法用法实例详解
  7. scp命令报错(IT IS POSSIBLE THAT SOMEONE IS DOING SOMETHING NASTY!)
  8. linux 查看磁盘、文件夹、文件大小(df du)
  9. a元素的两个重要功能和表格布局
  10. Java_Object
  11. Java编程的逻辑 (90) - 正则表达式 (下 - 剖析常见表达式)
  12. 如何在VMware系统中的ubuntu16.04中建立与win7系统的共享文件夹
  13. 《算法》BEYOND 部分程序 part 3
  14. Spring IOC 容器源码分析 - 创建单例 bean 的过程
  15. [Windows Azure] How to use the Table Storage Service
  16. 5款替代微软Visio的开源免费软件(转)
  17. [Python爬虫]煎蛋网OOXX妹子图爬虫(1)——解密图片地址
  18. 64_p7
  19. bzoj 1098
  20. Mac下node.js安装与卸载

热门文章

  1. [安卓基础] 009.组件Activity详解
  2. Cypress系列(4)- 解析 Cypress 的默认文件结构
  3. C语言/Linux命令行参数argc、argv[ ]详解
  4. 树莓派4B获取IP地址的几种简易方法
  5. Java实现 LeetCode 705 设计哈希集合(使用数组保存有没有被用过)
  6. Java实现BFS广度优先查找
  7. Centos宝塔安装NextCloud
  8. Grafana 插件地图Worldmap不显示
  9. k8s学习-存储
  10. Linux命令总结大全,包含所有linux命令