Metricbeat包的安装及简单使用

        Metricbeat包的安装及简单使用
系统数据采集
Python -> ES -> Grafana metricbeat的安装
metricbeat -> logstash -> ES -> Grafana系统监控
Metricbeat解决的问题:手动写Python比较麻烦
yum localinstall metricbeat-7.6.2-x86_64.rpm -y

metric默认配置说明
/etc/metricbeat/metricbeat.yml
/etc/metricbeat/modules.d/*.yml metric配置/etc/metricbeat/metricbeat.yml
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:
output.logstash:
hosts: ["192.168.238.90:5044"]

metricbeat输出到logstash

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:
output.kafka:
hosts: ["172.17.166.217:9092", "172.17.166.218:9092", "172.17.166.219:9092"] topic: 'test2'
partition.round_robin:
reachable_only: false required_acks: 1
compression: gzip
max_message_bytes: 1000000

metricbeat输出到kafka

metricbeat采集系统配置

# Module: system
# Docs: https://www.elastic.co/guide/en/beats/metricbeat/7.6/metricbeat-module-system.html
- module: system
period: 60s
metricsets:
- network
interfaces:
- eth0 - module: system
period: 10s
metricsets:
- cpu
- load
- memory
#- network
#- process
#- process_summary
#- socket_summary
#- entropy
#- core
#- diskio
#- socket
#- service
#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)($|/)' #q
#- module: system
# period: 15m
# metricsets:
# - uptime #- module: system
# period: 5m
# metricsets:
# - raid
# raid.mount_point: '/'

system.yml

        Metricbeat收集cpu内存等信息Grafana展示
Kibana上先清空之前的索引信息 load展示
metric: avg system.load.1
metric: avg system.load.5
metric: avg system.load.15
groupby: host.name.keyword alias: {{host.name.keyword}} {{metric}} {{field}}
interval: 1m cpu展示,如果显示异常,清空索引后再观察下
cpu.idle.pct
cpu.system.pct
cpu.user.pct
cpu.iowait.pct 磁盘使用率
system.filesystem.used.pct 内存使用率的展现
system.memory.actual.used.pct Metricbeat收集流量信息Grafana展示
需要配置单独收集某个网卡的流量/etc/metricbeat/modules.d/system.yml
- module: system
period: 60s
metricsets:
- network
interfaces:
- eth0 Grafana配置流量信息1m=60s 1Byte=8bit
avg(system.network.in.bytes) _value/60*8
Derivative(avg(system.network.in.bytes)) alias {{host.name.keyword}} in traffic
alias {{host.name.keyword}} out traffic

metricbeat modules enable nginx #开启模块

多台metricbeat安装-多台服务器采集
metricbeat安装
yum localinstall metricbeat-7.6.2-x86_64.rpm -y metric配置/etc/metricbeat/metricbeat.yml
拷贝之前一台服务器的 metricbeat配置/etc/metricbeat/modules.d/system.yml
拷贝之前一台服务器的 启动查看grafana
systemctl restart metricbeat Metricbeat采集Nginx信息Grafana展示
Nginx编译需要加以下选项
--with-http_stub_status_module Nginx配置新增
location /sjgstatus {
stub_status on;
access_log off;
allow 192.168.0.0/16;
deny all;
} Metricbeat支持nginx
metricbeat modules enable nginx 测试能否获取数据
curl xxx/sjgstatus Grafana配置nginx请求情况
avg(requests) _value / 60
Derivative
term by : service.address.keyword
alias: {{service.address.keyword}} accept persecond 模拟数据
while true; do curl 192.168.238.90; curl 192.168.238.90/test; sleep 1; done Metricbeat采集多台Nginx数据
安装Nginx,跟之前一样的配置 Metric新增一台Nginx监控
hosts: ["http://xxx","http://xxx"] 一台Metricbeat就能监控能通的Nginx

metricbeat开启nginx监测模块

Metricbeat采集Redis信息Grafana展示

安装redis
yum install redis -y 配置redis
设置绑定地址:0.0.0.0
设置密码:sjgpwd Metricbeat支持redis
metricbeat modules enable redis 监控redis每秒连接数
received persecond _value / 60
Derivative
grouby: service.address
alias: {{service.address.keyword}} received persecond 模拟数据
while true; do redis-cli -a sjgpwd set a b; redis-cli -a sjgpwd get a; sleep 1; done metricbeat还支持收集很多模块,见以下目录
/etc/metricbeat/modules.d/

redis

Metricbeat采集Mysql监控数据

Metricbeat采集Mysql监控数据
安装mysql服务器准备
yum install mariadb-server -y
systemctl restart mariadb
mysql_secure_installation 监控权限开启
grant usage on *.* to 'monitor'@'192.168.%' identified by 'sjgpwd';
flush privileges; 测试能否正常登录
mysql -h 192.168.238.92 -umonitor -psjgpwd -A 开启监控mysql模块
metricbeat modules enable mysql 配置mysql监控
hosts: ["monitor:sjgpwd@tcp(xxx:3306)/"] 监控mysql delete persecond
delete persecond _value / 60
Derivative
grouby: service.address
alias: {{service.address.keyword}} delete persecond 模拟数据,观察grafana
use mysql;
create table test (id int);
mysql -psjgpwd -A -e "use mysql; delete from test"

mysql

Metricbeat根据不同类型定义不同索引

metricbeat采集
metricbeat modules enable system
metricbeat modules enable redis
metricbeat modules enable nginx
metricbeat modules enable mysql Logstash区分system还是redis 还是其它
output {
if [service][type] == "mysql" {
elasticsearch {
hosts => ["http://192.168.238.90:9200", "http://192.168.238.92:9200"]
user => "elastic"
password => "sjgpwd"
index => "sjgmysql-%{+YYYY.MM.dd}"
}
}
else if [service][type] == "redis" {
elasticsearch {
hosts => ["http://192.168.238.90:9200", "http://192.168.238.92:9200"]
user => "elastic"
password => "sjgpwd"
index => "sjgredis-%{+YYYY.MM.dd}"
}
}
else {
elasticsearch {
hosts => ["http://192.168.238.90:9200", "http://192.168.238.92:9200"]
user => "elastic"
password => "sjgpwd"
index => "sjgother-%{+YYYY.MM.dd}"
}
}
}

logstash配置

Kibana页面上ES索引监控的开启

Kibana监控的开启
开启kibana监控
使用metricbeat 启动metricbeat
metricbeat modules enable elasticsearch-xpack
metricbeat modules disable 所有 配置文件elasticsearch-xpack.yml
- module: elasticsearch
metricsets:
- ccr
- cluster_stats
- enrich
- index
- index_recovery
- index_summary
- ml_job
- node_stats
- shard
period: 10s
hosts: ["http://192.168.238.90:9200", "http://192.168.238.92:9200"]
username: "elastic"
password: "sjgpwd"
xpack.enabled: true metricbeat配置:/etc/metricbeat/metricbeat.yml
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: output.elasticsearch:
hosts: ["192.168.238.90:9200", "192.168.238.92:9200"]
username: "elastic"
password: "sjgpwd" Python测试监控是否正常
import time
import datetime
from elasticsearch import Elasticsearch
es = Elasticsearch(['http://elastic:sjgpwd@192.168.238.90:9200', 'http://elastic:sjgpwd@192.168.238.92:9200'])
for i in range(10000):
curtime=datetime.datetime.utcnow().isoformat()
body = {"name": "sjg{0}".format(i), "@timestamp": curtime, "sjgcount": i}
es.index(index='sjg', body=body)
time.sleep(1)
print('insert {0}'.format(i))

kibana监测es

ELK集群之metricbeat(9)的更多相关文章

  1. Centos7中ELK集群安装流程

    Centos7中ELK集群安装流程   说明:三个版本必须相同,这里安装5.1版. 一.安装Elasticsearch5.1   hostnamectl set-hostname elk vim /e ...

  2. ansible playbook部署ELK集群系统

    一.介绍 总共4台机器,分别为 192.168.1.99 192.168.1.100 192.168.1.210 192.168.1.211 服务所在机器为: redis:192.168.1.211 ...

  3. Kibana安装(图文详解)(多节点的ELK集群安装在一个节点就好)

    对于Kibana ,我们知道,是Elasticsearch/Logstash/Kibana的必不可少成员. 前提: Elasticsearch-2.4.3的下载(图文详解) Elasticsearch ...

  4. elk集群配置配置文件中节点数配多少

    配置elk集群时,遇到,elasticsearch配置文件中的一个配置discovery.zen.minimum_master_nodes: 2.这里是三配的2 看到某一位的解释是这样:为了避免脑裂, ...

  5. Filebeat-1.3.1安装和设置(图文详解)(多节点的ELK集群安装在一个节点就好)(以Console Output为例)

    前期博客 Filebeat的下载(图文讲解) 前提 Elasticsearch-2.4.3的下载(图文详解) Elasticsearch-2.4.3的单节点安装(多种方式图文详解) Elasticse ...

  6. 通过docker搭建ELK集群

    单机ELK,另外两台服务器分别有一个elasticsearch节点,这样形成一个3节点的ES集群. 可以先尝试单独搭建es集群或单机ELK https://www.cnblogs.com/lz0925 ...

  7. ELK集群搭建

    基于5台虚拟机,搭建ELK集群. 方案: 1. ELK是日志分析平台,而不是一款软件,是一整套解决方案,是三个软件产品的首字母缩写,ELK分别代表: Elasticsearch:负责日志检索和储存 L ...

  8. 搭建ELK 集群 rpm安装

    上次是使用docker搭建的ELK,三个软件都跑在一台机器的一个docker中,这个就当是测试环境吧. 下面开始搭建正式环境下的ELK集群. 三台服务器 A:logstash B:Elasticsea ...

  9. ELK集群部署实例(转)

    转载自:http://blog.51cto.com/ckl893/1772287,感谢原博. 一.ELK说明 二.架构图 三.规划说明 四.安装部署nginx+logstash 五.安装部署redis ...

随机推荐

  1. 三分钟图解 MVCC,看一遍就懂

    前文我们介绍了 InnoDB 存储引擎在事务隔离级别 READ COMMITTED 和 REPEATABLE READ(默认)下会开启一致性非锁定读,简单回顾下:所谓一致性非锁定读就是每行记录可能存在 ...

  2. isnull与ifnull适用数据库

    根据业务流程去查询某个数据表的某个字段的最大值: 直接用的select max(code) from base_area; 大多数情况没有问题,有个特殊点:如果数据表里边没有数据,且返回类型时int时 ...

  3. WPF进阶技巧和实战07--自定义元素01

    完善和扩展标准控件的方法: 样式:可使用样式方便地重用控件属性的集合,甚至可以使用触发器应用效果 内容控件:所有继承自ContentControl类的控件都支持嵌套的内容.使用内容控件,可以快速创建聚 ...

  4. PyTorch模型读写、参数初始化、Finetune

    使用了一段时间PyTorch,感觉爱不释手(0-0),听说现在已经有C++接口.在应用过程中不可避免需要使用Finetune/参数初始化/模型加载等. 模型保存/加载 1.所有模型参数 训练过程中,有 ...

  5. JavaWeb#JSP内置对象

    [1.JSP内置对象简介] 内置对象:不加声明就可以在JSP页面脚本中使用的成员变量.(使用这些对象可以更容易收集客户端发送的请求信息,响应客户端的请求及存储客户信息.) 主要介绍:out,reque ...

  6. Java多线程--实现同步的9种方法

    我们通常说的保持同步,其实就是对共享资源的保护.在单线程模型中, 我们永远不用担心"多个线程试图同时使用同一个资源的问题", 但是有了并发, 就有可能发生多个线程竞争同一个共享资源 ...

  7. Spring IOC Container原理解析

    Spring Framework 之 IOC IOC.DI基础概念 关于IOC和DI大家都不陌生,我们直接上martin fowler的原文,里面已经有DI的例子和spring的使用示例 <In ...

  8. Tomcat 源码环境搭建

    Tomcat 源码搭建 下载源码 下载地址 :https://tomcat.apache.org/download-80.cgi#8.5.35 下载之后解压缩 导入Idea 添加pom.xml文件 & ...

  9. pycharm中的terminal和Windows命令提示符有什么区别?二者用pip安装的包是不是位于相同位置?

    那要看pycharm使用了什么shell,可以在设置->工具->终端里查看shell path.如果使用的是cmd.exe那就没区别.pycharm终端和Windows命令提示符用pip安 ...

  10. 封装ARX给.Net调用

    1:创建工程名.def的文件,内容如下: 2:def文件位置: 3:属性页配置: 4:acrxEntryPoint.cpp下面添加如下代码(可以传参数) 5:c#调用 怕自己忘记,记录一下.