elasticSearch插件metricbeat收集nginx的度量指标
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的度量指标的更多相关文章
- ELK Stack (2) —— ELK + Redis收集Nginx日志
ELK Stack (2) -- ELK + Redis收集Nginx日志 摘要 使用Elasticsearch.Logstash.Kibana与Redis(作为缓冲区)对Nginx日志进行收集 版本 ...
- elasticSearch插件的安装以及使用nginx的modles收集nginx的日志
1.首先在windows环境上搭建es的集群 集群的配置如下 #node01的配置: cluster.name: es-itcast-cluster node.name: node01 node.ma ...
- logstash收集nginx访问日志
logstash收集nginx访问日志 安装nginx #直接yum安装: [root@elk-node1 ~]# yum install nginx -y 官方文档:http://nginx.org ...
- 安装logstash5.4.1,并使用grok表达式收集nginx日志
关于收集日志的方式,最简单性能最好的应该是修改nginx的日志存储格式为json,然后直接采集就可以了. 但是实际上会有一个问题,就是如果你之前有很多旧的日志需要全部导入elk上查看,这时就有两个问题 ...
- ELK 二进制安装并收集nginx日志
对于日志来说,最常见的需求就是收集.存储.查询.展示,开源社区正好有相对应的开源项目:logstash(收集).elasticsearch(存储+搜索).kibana(展示),我们将这三个组合起来的技 ...
- ELK之elasticsearch插件导致filebeat没有上传日志至elasticsearch解决办法
使用filebeat收集nginx发现日志为上传,elasticsearch没有日志,kibana没有展示 查看filebeat日志 日志目录为/var/log/filebeat 下面有多个日志文件 ...
- elasticsearch+kibana+metricbeat安装部署方法
elasticsearch+kibana+metricbeat安装部署方法 本文是elasticsearch + kibana + metricbeat,没有涉及到logstash部分.通过beat收 ...
- ELK filter过滤器来收集Nginx日志
前面已经有ELK-Redis的安装,此处只讲在不改变日志格式的情况下收集Nginx日志. 1.Nginx端的日志格式设置如下: log_format access '$remote_addr - $r ...
- ELK日志系统之使用Rsyslog快速方便的收集Nginx日志
常规的日志收集方案中Client端都需要额外安装一个Agent来收集日志,例如logstash.filebeat等,额外的程序也就意味着环境的复杂,资源的占用,有没有一种方式是不需要额外安装程序就能实 ...
随机推荐
- [PHP插件教程]003.PhpRedis
PhpRedis 介绍 Mac安装步骤 安装Redis 安装PhpRedis 示例代码 介绍 Redis是一个高性能的key-value数据库. Redis提供了Java,C/C++,C#,PHP,J ...
- MVC案例之多个请求对应一个servlet
CustomerServlet package com.aff.mvcapp.servlet; import java.io.IOException; import java.lang.reflec ...
- 设计并测试Trapezium类 代码参考
#include <iostream> using namespace std; class Trapezium { private: int x1,y1,x2,y2,x3,y3,x4,y ...
- 单片机提高ADC精度总结
在常用传感器中,模数转换器是其中至关重要的环节,模数转换器的精度以及系统的成本直接影响到系统的实用性.因此.如何提高模数转换器的精度和降低系统的成本是衡量系统是否具有实际应用价值的标准. 图 1 ...
- 容器技术之Dockerfile (一)
在前边的随笔中我们聊到了docker的基本命令,镜像,网络,存储卷以及基于现有容器制做docker镜像,相关随笔可参考https://www.cnblogs.com/qiuhom-1874/categ ...
- 线程池续:你必须要知道的线程池submit()实现原理之FutureTask!
前言 上一篇内容写了Java中线程池的实现原理及源码分析,说好的是实实在在的大满足,想通过一篇文章让大家对线程池有个透彻的了解,但是文章写完总觉得还缺点什么? 上篇文章只提到线程提交的execute( ...
- day1_计算机基础
一.计算器5大组成:计算机硬件:(计算机是奴隶) 1.五大组成 控制器 运算器 存储器I/O:内存+外存 ...
- Chisel3-创建工程并转换为Verilog代码
https://mp.weixin.qq.com/s/ie0R3v60IcrI6beTXHrgSg 基于Intellj IDEA+Scala插件模式开发 因为Chisel内嵌于Scala,所以 ...
- Spring ( 四 )Spring的AOP动态代理、切面编程
个人博客网:https://wushaopei.github.io/ (你想要这里多有) 一.AOP切面编程 1.什么是AOP AOP是面向切面编程.全称:Aspect Oriented Pro ...
- Java实现 LeetCode 667 优美的排列 II(暴力)
667. 优美的排列 II 给定两个整数 n 和 k,你需要实现一个数组,这个数组包含从 1 到 n 的 n 个不同整数,同时满足以下条件: ① 如果这个数组是 [a1, a2, a3, - , an ...