ELK · Metricbeat的使用

三、MetricBeat

1、下载metricbeat

[root@k8s-fengfan elk2.2.2]# wget https://artifacts.elastic.co/downloads/beats/metricbeat/metricbeat-6.2.2-linux-x86_64.tar.gz
[root@k8s-fengfan elk2.2.2]# tar xvf metricbeat-6.2.2-linux-x86_64.tar.gz

image-20201204162523720

Metricbeat有2部分组成,一部分是Module,另一部分为Metricset。

  • Module

收集的对象,如:mysql、redis、操作系统等;

  • Metricset

收集指标的集合,如:cpu、memory、network等;

2、配置监控指标信息

1、配置文件metricbeat.yml

这边测试直接输出到elasticseatch并且配置开启kibana的Dashboard

setup.dashboards.enabled: true 开启自动创建仪表盘监控

metricbeat.config.modules:
  path: ${path.config}/modules.d/*.yml
  reload.enabled: false

setup.template.settings:
  index.number_of_shards: 1
  index.codec: best_compression
setup.kibana:
  host: "k8s-fengfan:5601"
setup.dashboards.enabled: true
output.elasticsearch:
  hosts: ["k8s-fengfan:9200"]
#启动命令
[root@k8s-fengfan metricbeat-6.2.2-linux-x86_64]# ./metricbeat -e

image-20201224110325553

2、配置监控

metricbeat默认开启了system模块的监控,这边开启了docker的监控

[root@k8s-fengfan metricbeat-6.2.2-linux-x86_64]# ./metricbeat modules list
Enabled:
docker
system

Disabled:
aerospike
apache
ceph
couchbase
dropwizard
elasticsearch
etcd
golang
graphite
haproxy
http
jolokia
kafka
kibana
kubernetes
logstash
memcached
mongodb
mysql
nginx
php_fpm
postgresql
prometheus
rabbitmq
redis
uwsgi
vsphere
windows
zookeeper
1、监控system模块

开启system监控然后启动metricbeat

# 开启system监控
[root@k8s-fengfan metricbeat-6.2.2-linux-x86_64]# ./metricbeat modules enable system
# 启动metricbeat
[root@k8s-fengfan metricbeat-6.2.2-linux-x86_64]# ./metricbeat -e	

system.yml配置

- module: system
  period: 10s
  metricsets:
    - cpu
    - load
    - memory
    - network
    - process
    - process_summary
    #- core
    #- diskio
    #- socket
  processes: ['.*']
  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

页面展示

1、 [Metricbeat System] Overview

image-20201224105738377

2、[Metricbeat System] Host overview

image-20201224105623756

image-20201224105654285

3、 [Metricbeat System] Containers overview

image-20201224104235605

2、监控docker模块

开启docker监控

# 开启docker监控
[root@k8s-fengfan metricbeat-6.2.2-linux-x86_64]# ./metricbeat modules enable docker
# 启动metricbeat
[root@k8s-fengfan metricbeat-6.2.2-linux-x86_64]# ./metricbeat -e	

页面展示

image-20201224104725046

3、监控nginx模块

nginx的监控需要一些额外的配置

nginx应用的nginx.conf配置需要加上以下内容,因为metricbeat的nginx插件默认指定了 server_status_path: "server-status"

location = /server-status{
	stub_status;
}

然后重启nginx

# 重启nginx
 ./sbin/nginx -s reload
# 如果报错  需要重新安装的时候指定一下
./configure --prefix=/usr/local/nginx --with-http_stub_status_module
make && make install

image-20201224113416169

metricbeat的nginx模块配置如下:

- module: nginx
  metricsets: ["stubstatus"]
  period: 10s

  # Nginx hosts
  hosts: ["http://k8s-fengfan"]

  # Path to server status. Default server-status
  server_status_path: "server-status"
# 开启docker监控
[root@k8s-fengfan metricbeat-6.2.2-linux-x86_64]# ./metricbeat modules enable nginx
# 启动metricbeat
[root@k8s-fengfan metricbeat-6.2.2-linux-x86_64]# ./metricbeat -e	

页面展示

image-20201224113211096

3、完整的metricbeat索引mapping

metric_mapping.json下载

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值