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上面就可以看到对于的仪表盘信息了

elasticSearch插件metricbeat收集nginx的度量指标的更多相关文章

  1. ELK Stack (2) —— ELK + Redis收集Nginx日志

    ELK Stack (2) -- ELK + Redis收集Nginx日志 摘要 使用Elasticsearch.Logstash.Kibana与Redis(作为缓冲区)对Nginx日志进行收集 版本 ...

  2. elasticSearch插件的安装以及使用nginx的modles收集nginx的日志

    1.首先在windows环境上搭建es的集群 集群的配置如下 #node01的配置: cluster.name: es-itcast-cluster node.name: node01 node.ma ...

  3. logstash收集nginx访问日志

    logstash收集nginx访问日志 安装nginx #直接yum安装: [root@elk-node1 ~]# yum install nginx -y 官方文档:http://nginx.org ...

  4. 安装logstash5.4.1,并使用grok表达式收集nginx日志

    关于收集日志的方式,最简单性能最好的应该是修改nginx的日志存储格式为json,然后直接采集就可以了. 但是实际上会有一个问题,就是如果你之前有很多旧的日志需要全部导入elk上查看,这时就有两个问题 ...

  5. ELK 二进制安装并收集nginx日志

    对于日志来说,最常见的需求就是收集.存储.查询.展示,开源社区正好有相对应的开源项目:logstash(收集).elasticsearch(存储+搜索).kibana(展示),我们将这三个组合起来的技 ...

  6. ELK之elasticsearch插件导致filebeat没有上传日志至elasticsearch解决办法

    使用filebeat收集nginx发现日志为上传,elasticsearch没有日志,kibana没有展示 查看filebeat日志 日志目录为/var/log/filebeat  下面有多个日志文件 ...

  7. elasticsearch+kibana+metricbeat安装部署方法

    elasticsearch+kibana+metricbeat安装部署方法 本文是elasticsearch + kibana + metricbeat,没有涉及到logstash部分.通过beat收 ...

  8. ELK filter过滤器来收集Nginx日志

    前面已经有ELK-Redis的安装,此处只讲在不改变日志格式的情况下收集Nginx日志. 1.Nginx端的日志格式设置如下: log_format access '$remote_addr - $r ...

  9. ELK日志系统之使用Rsyslog快速方便的收集Nginx日志

    常规的日志收集方案中Client端都需要额外安装一个Agent来收集日志,例如logstash.filebeat等,额外的程序也就意味着环境的复杂,资源的占用,有没有一种方式是不需要额外安装程序就能实 ...

随机推荐

  1. [PHP学习教程 - 心得]001.偷龙转凤技巧10则(Remember Tips)

    引言:PHP当中的一些猬锁技巧,比较基础,想起就发贴总结一下,老鸟换个姿势飘过去就是. [技巧]应该属于“方法”的一个范畴,主要指对一种生活或工作方法的熟练和灵活运用.[五笔]RFAG. 话不多说,下 ...

  2. 小工具之apk黑屏自动检测

    在打包测试的时候经常发送给测试组之后,发现已进入游戏就黑屏,这个就浪费了测试组的精力,如果要测试多款产品的话,就会因为黑屏问题做很多无用功,这是程序就需要在发给测试的时候自己先测试产品会不会黑屏.同样 ...

  3. xxd十六进制编辑器的安装

    一.背景:在vi中使用命令:%!xxd无法进行十六进制编辑,为缺少xxd命令所致 二.yum直接安装xxd无法成功[root@ELK ~]# yum install xxd已加载插件:fastestm ...

  4. ES6-解析赋值

    1.注意事项 A.左右两边结构必须一样 B.右边必须是个东西 C.声明和赋值不能分开(必须在一句话里完成) 2.代码如下 <!DOCTYPE html> <html lang=&qu ...

  5. Rocket - decode - 几个问题

    https://mp.weixin.qq.com/s/pMsK_E4mQrm3QXdnp7nDPQ   讨论指令解码部分遗留的几个问题.     1. 最小项与蕴含项之间的关系   参考链接: htt ...

  6. Java实现ACMGoShopping

    ACMGoShopping Description 最近的YJ运气特别好,这不,他在路边摊买彩票,居然中了大奖.秉着见者有份的原则,他准备请咱们学校ACM训练基地的全体队员逛商场. 赶巧学校旁边有一家 ...

  7. Java中线程的操作状态

    start() 线程开始运行 sleep() 当前线程暂停休息 括号里面是多长时间以毫秒为单位 wait() 当前线程等待 notify() 线程wait后用这个方法唤醒 notifyAll() 把所 ...

  8. Java实现 LeetCode 240 搜索二维矩阵 II

    public static boolean searchMatrix(int[][] matrix, int target) { if(matrix.length == 0) return false ...

  9. java实现第七届蓝桥杯机器人塔

    机器人塔 X星球的机器人表演拉拉队有两种服装,A和B. 他们这次表演的是搭机器人塔. 类似: A B B A B A A A B B B B B A B A B A B B A 队内的组塔规则是: A ...

  10. uniapp每隔几秒执行一下网络请求(h5端亲测可以,其他端未测试)

    methods: { //执行网络请求 run() { uni.request({ method: 'GET',//请求方式 url: ‘’//请求地址 }).then(res=>{ conso ...