centos7安装Metricbeat7.6.0采集nginx指标
下载配置
下载 metricbeat
官网下载地址:https://www.elastic.co/cn/downloads/past-releases#metricbeat
网盘地址(7.6.0):
链接:https://pan.baidu.com/s/1J9UJ3pPCwqJnkQ9a3Qe69w
提取码:0uko
#下载后放在/opt/software
tar -zxvf metricbeat-7.6.0-linux-x86_64.tar.gz -C /usr/local
cd /usr/local/metricbeat-7.6.0-linux-x86_64/
配置 metricbeat.yml
vim metricbeat.yml
修改elasticsearch配置块
#-------------------------- Elasticsearch output ------------------------------
output.elasticsearch:
# Array of hosts to connect to.
hosts: ["192.168.25.132:9200","192.168.25.133:9200","192.168.25.134:9200"]
启动
#启动命令
./metricbeat -e
然后打开Elasticsearch,发现多了一个Metricbeat索引
数据正在实时采集:
Module
#查看当前模块列表
./metricbeat modules list
Enabled:
system
Disabled:
activemq
aerospike
apache
appsearch
aws
azure
beat
beat-xpack
ceph
cockroachdb
consul
coredns
couchbase
couchdb
docker
dropwizard
elasticsearch
elasticsearch-xpack
envoyproxy
etcd
golang
googlecloud
graphite
haproxy
http
jolokia
kafka
kibana
kibana-xpack
kubernetes
kvm
logstash
logstash-xpack
memcached
mongodb
mssql
munin
mysql
nats
nginx
oracle
php_fpm
postgresql
prometheus
rabbitmq
redis
sql
stan
statsd
tomcat
traefik
uwsgi
vsphere
windows
zookeeper
system模块默认是启用的,这边可以查看system module配置
cd modules.d/
vim system.yml
# Module: system
# Docs: https://www.elastic.co/guide/en/beats/metricbeat/7.6/metricbeat-module-system.html
- module: system
period: 10s
metricsets:
- cpu
- load
- memory
- network
- process
- process_summary
- socket_summary
#- entropy
#- core
#- diskio
#- socket
#- services
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 Module
采集nginx指标数据:nginx需要开启状态指标查询,才能查到指标数据
#重新编译安装
cd /usr/local/nginx-1.14.1
./configure --prefix=/usr/local/nginx --with-http_stub_status_module
make
make install
#修改nginx配置
cd /usr/local/nginx
vim conf/nginx.conf
#在server块加上这部分
location /nginx-status {
stub_status on;
access_log off;
}
验证测试,打开 http://192.168.25.132/nginx-status
结果说明:
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))
nginx module 配置文件
#启用nginx module
./metricbeat modules enable nginx
cd modules.d/
vim nginx.yml
#配置如下
- module: nginx
period: 10s
# Nginx hosts
hosts: ["http://192.168.25.132"]
# Path to server status. Default server-status
server_status_path: "nginx-status"
启动metricbeat
./metricbeat -e
查看Elasticsearch,nginx指标数据已经采集进来
您可能感兴趣的文章:
centos7怎么安装php
centos系统下nginx宝塔快速安装
php集群如何实现
多规则替换过滤nginx模块nginx_substitutions_filter
避坑!用 Docker 搞定 PHP 开发环境搭建
Nginx负载均衡和LVS负载均衡的比较分析
如何在CentOS和RHEL和Fedora上安装NGINX Web服务器
nginx和php-fpm通信,使用unix socket还是TCP?
PHP3年应该掌握哪些
Centos7安装并配置mysql5.6完美教程