zoukankan      html  css  js  c++  java
  • 【Beats】Metricbeat快速入门(二十二)

    Metricbeat介绍

      Metricbeat是一种轻量级的托运人,可以将其安装在服务器上,以定期从操作系统和服务器上运行的服务收集指标。Metricbeat会收集它收集的度量标准和统计信息,并将其运送到指定的输出,例如Elasticsearch或Logstash。

      Metricbeat通过从服务器上运行的系统和服务收集指标来帮助您监视服务器。

      官网地址:https://www.elastic.co/cn/beats/metricbeat

      文档地址:https://www.elastic.co/guide/en/beats/metricbeat

    Metricbeat原理

      Metricbeat由模块和指标集组成。Metricbeat 模块定义了从特定服务(例如Redis,MySQL等)收集数据的基本逻辑。该模块指定有关服务的详细信息,包括如何连接,收集度量的频率以及收集哪些度量。

      每个模块都有一个或多个指标集。甲metricset是模块取和结构中的数据的一部分。度量标准集不是将每个度量标准收集为单独的事件,而是在对远程系统的单个请求中检索多个相关度量标准的列表。因此,例如,Redis模块提供了一个info 度量标准集,该度量标准集通过运行INFO命令并解析返回的结果来从Redis收集信息和统计信息 。

      

    Metricbeat使用

      环境准备

      系统环境:CentOS 7.4

      ES版本:7.6.1

      Kibana版本:7.6.1

      1、下载Metricbeat安装包,metricbeat-7.6.1-linux-x86_64.tar.gz

      2、解压安装包

        命令:tar -zxvf metricbeat-7.6.1-linux-x86_64.tar.gz

        

      3、查看已经启动的module

        查看module命令:./metricbeat modules list

        启动系统模块命令:./metricbeat modules enable system

        关闭系统模块命令:./metricbeat modules disable system

        

        可以发现只有system模块已启动

      4、查看system模块配置

        命令:vim modules.d/system.yml

        

      5、编辑metricbeat.yml配置文件

        命令:vim metricbeat.yml

    1 output.elasticsearch:
    2   # Array of hosts to connect to.
    3   hosts: ["127.0.0.1:9200"]
    4 
    5   # Authentication credentials - either API key or username/password.
    6   #api_key: "id:api_key"
    7   username: "elastic"
    8   password: "123456"

      6、启动metricbeat

        启动命令:./metricbeat -e (使用默认文件)

        启动命令(指定配置文件):./metricbeat -e -c metricbeat.yml

        后台启动:nohup ./metricbeat -e &

        关闭命令:

      • 查看metricbeat进程:ps -ef|grep metricbeat
      • 杀死进程:kill pid

      7、查看ES数据

        1)ES中增加了索引 metribeat-7.6.1-2020.06.25-000001

          

        2)索引 metribeat-7.6.1-2020.06.25-000001 数据内容如下:

      1 {
      2     "_index": "metricbeat-7.6.1-2020.06.25-000001",
      3     "_type": "_doc",
      4     "_id": "1CwB6XIBk_UZVEKb_T3p",
      5     "_version": 1,
      6     "_score": 1,
      7     "_source": {
      8         "@timestamp": "2020-06-25T01:05:15.283Z",
      9         "metricset": {
     10             "period": 10000,
     11             "name": "cpu"
     12         },
     13         "event": {
     14             "module": "system",
     15             "duration": 113555,
     16             "dataset": "system.cpu"
     17         },
     18         "service": {
     19             "type": "system"
     20         },
     21         "system": {
     22             "cpu": {
     23                 "softirq": {
     24                     "pct": 0
     25                 },
     26                 "system": {
     27                     "pct": 0
     28                 },
     29                 "irq": {
     30                     "pct": 0
     31                 },
     32                 "idle": {
     33                     "pct": 0
     34                 },
     35                 "iowait": {
     36                     "pct": 0
     37                 },
     38                 "nice": {
     39                     "pct": 0
     40                 },
     41                 "total": {
     42                     "pct": 0
     43                 },
     44                 "user": {
     45                     "pct": 0
     46                 },
     47                 "steal": {
     48                     "pct": 0
     49                 },
     50                 "cores": 1
     51             }
     52         },
     53         "ecs": {
     54             "version": "1.4.0"
     55         },
     56         "host": {
     57             "name": "H__D",
     58             "hostname": "H__D",
     59             "architecture": "x86_64",
     60             "os": {
     61                 "version": "7 (Core)",
     62                 "family": "redhat",
     63                 "name": "CentOS Linux",
     64                 "kernel": "3.10.0-1062.18.1.el7.x86_64",
     65                 "codename": "Core",
     66                 "platform": "centos"
     67             },
     68             "id": "f0f31005fb5a436d88e3c6cbf54e25aa",
     69             "containerized": false
     70         },
     71         "agent": {
     72             "id": "e7b63bfc-e555-4e33-b186-9e5bc5b932f3",
     73             "version": "7.6.1",
     74             "type": "metricbeat",
     75             "ephemeral_id": "20796939-2045-4837-a7d7-630629681e50",
     76             "hostname": "H__D"
     77         }
     78     }
     79 } {
     80     "settings": {
     81         "index": {
     82             "number_of_shards": "2",
     83             "number_of_replicas": "0"
     84         }
     85     },
     86     "mappings": {
     87         "person": {
     88             "properties": {
     89                 "name": {
     90                     "type": "text"
     91                 },
     92                 "age": {
     93                     "type": "integer"
     94                 },
     95                 "mail": {
     96                     "type": "keyword"
     97                 },
     98                 "hobby": {
     99                     "type": "text"
    100                 }
    101             }
    102         }
    103     }
    104 }
    View Code

      8、还可以拓展配置,将数据到 Kibana仪表板 中展示

        参考:【Filebeat】 与Kibana仪表板(二十一) 

  • 相关阅读:
    centos8 将SSSD配置为使用LDAP并要求TLS身份验证
    Centos8 搭建 kafka2.8 .net5 简单使用kafka
    .net core 3.1 ActionFilter 拦截器 偶然 OnActionExecuting 中HttpContext.Session.Id 为空字符串 的问题
    Springboot根据不同环境加载对应的配置
    VMware Workstation12 安装 Centos8.3
    .net core json配置文件小结
    springboot mybatisplus createtime和updatetime自动填充
    .net core autofac依赖注入简洁版
    .Net Core 使用 redis 存储 session
    .Net Core 接入 RocketMQ
  • 原文地址:https://www.cnblogs.com/h--d/p/13191412.html
Copyright © 2011-2022 走看看