栏目分类:
子分类:
返回
名师互学网用户登录
快速导航关闭
当前搜索
当前分类
子分类
实用工具
热门搜索
名师互学网 > IT > 前沿技术 > 大数据 > 大数据系统

Elastic stack 认证:可观测性认证工程师 (ECOE, elastic certified observability engineer)指标采集(Metric)

Elastic stack 认证:可观测性认证工程师 (ECOE, elastic certified observability engineer)指标采集(Metric)

指标监控

elastic stack 的指标监控可以通过 metricbeat 配合几十种的 module 对各种服务器环境及服务实例自身的状态信息进行采集和上报。

配置启动
    安装修改相关配置
      输出到 ES
        output.elasticsearch:
           hosts: ["myEShost:9200"]
           username: "metricbeat_internal"
           password: "YOUR_PASSWORD" 
      
      (可选)初始化 Kibana(如果 Kibana 和 ES 在同一集群可跳过)
        setup.kibana:
           host: "mykibanahost:5601" 
           username: "my_kibana_user"  
           password: "{pwd}"
      
    开启需要的采集模块
    ./metricbeat modules enble ${module1} ${module2}
    
    在集群中初始化采集模块相关配置
    ./metricbeat setup -e
    
    启动 metricbeat
      给配置文件赋予权限
      sudo chown root metricbeat.yml 
      sudo chown root modules.d/system.yml
      
      启动
      sudo ./metricbeat -e &
      
项目路径
目录描述配置 key默认路径deb / rpmdockerzip, tar.gz, or tgzbrew
home安装目录path.home-/usr/share/metricbeat/usr/share/metricbeat{extract.path}/usr/local/var/homebrew/linked/metricbeat-full
bin应用的执行目录-{path.home}/bin/usr/share/metricbeat/bin/usr/share/metricbeat{extract.path}/usr/local/var/homebrew/linked/metricbeat-full/bin
config配置文件目录path.config{path.home}/etc/metricbeat/usr/share/metricbeat{extract.path}/usr/local/etc/metricbeat
data数据目录path.data{path.home}/data/var/lib/metricbeat/usr/share/metricbeat/data{extract.path}/data/usr/local/var/lib/metricbeat
logs日志目录path.logs{path.home}/logs/var/log/metricbeat/usr/share/metricbeat/logs{extract.path}/logs/usr/local/ver/log/metricbeat
常见命令

    帮助(help)

    ./metricbeat -h
    
    ./metricbeat help export
    

    导出(export),可以导出配置和看板等

    ./metricbeat export config --es.version 7.10.2
    
    ./metricbeat export dashboard --id="xx" > dashboard.json
    

    keystore,管理密钥相关配置,doc

    ./metricbeat keystore create
    

    模块(modules),相关配置在 modules.d 文件夹里,通过命令开启/关闭模块,doc

    ./metricbeat modules list
    
    ./metricbeat modules enable mysql
    

    初始化(setup),在目标集群里初始化对应的模板、pipeline、看板等,doc

    ./metricbeat setup -e
    
    ./metricbeat setup --dashboards -e
    
常规配置

    示例文件 (doc)

    全局配置

      metricbeat.max_start_delay 最大延迟开始时间
        metricbeat 在启动(重启)时会随机一个 [0, max_start_delay) 时间,以免大量实例同时启动产生的惊群效应如果设为 0 则禁止延迟启动默认为 10s
      timeseries.enabled 时序标记
        metricbeat 会在每一个上报的事件数据包里添加时序标记(timeseries.instance)默认值为 true (添加)

    常规配置

      name 传入字符串,指定当前采集实例的名字,会被放在 event 里一起上报(agent.name)
        不设的话默认值是当前服务器的 hostname
      tags 传入字符串数组,指定当前采集实例的标签组,方便在 ES 里做数据聚合(可选)fields 附加字段,可以在上报数据中添加指定内容
        默认放在 fields 字段对应的对象里可以通过开启 fields_under_root 把这些数据放在顶层
      processor (doc)max_procs 最大可用 CPU 核数,默认是当前系统可用核数

    配置文件

      默认位于 modules.d/*.yml通过配置进行指定
      metricbeat.config.modules:
        path: ${path.config}/modules.d/*.yml
      
      热加载
        reload.enabled 开启热加载reload.period 轮询时间间隔,尽量不要设置小于 1s,因为数据加载可能就需要 1s 了
      metricbeat.config.modules:
        path: ${path.config}/modules.d/*.yml
        reload.enabled: true
        reload.period: 10s
      

    output 输出

      主要需要关注的:
        Elasticsearch Service(doc)Elasticsearch(doc)Logstash(doc)Kafka(doc)File(doc)Console(doc)

    SSL(doc)

      配置开启
      output.elasticsearch.hosts: ["https://192.168.1.42:9200"]
      output.elasticsearch.ssl.certificate_authorities: ["/etc/pki/root/ca.pem"]
      output.elasticsearch.ssl.certificate: "/etc/pki/client/cert.pem"
      output.elasticsearch.ssl.key: "/etc/pki/client/cert.key"
      
      配置说明
        enabled 是否开启certificate_authorities 认证证书,支持路径数组,也可以直接把证书在里面certificate 认证信息,支持路径,也可以直接贴在里面key 密钥,支持路径,也可以直接贴在里面verification_mode认证模式,默认 full,同时支持 certificate 和 none

    ilm (doc)

      配置
      setup.ilm.enabled: auto
      setup.ilm.rollover_alias: "metricbeat"
      setup.ilm.pattern: "{now/d}-000001" 
      
      配置说明
        setup.ilm.enabled 配置开启setup.ilm.rollover_alias 滚动别名setup.ilm.pattern 滚动命名策略setup.ilm.policy_name 策略名称,默认 metricbeat

    index template (doc)

      配置
      setup.template.name: "metricbeat"
      setup.template.pattern: "metricbeat-*"
      
      配置说明
        setup.template.enabled 配置开启setup.template.name 名称setup.template.pattern 索引匹配策略setup.template.settings 指定 settings

    kibana (doc)

      配置
      setup.kibana.host: "192.0.2.255:5601"
      setup.kibana.protocol: "http"
      setup.kibana.path: /kibana
      setup.kibana.ssl.enabled: true
      setup.kibana.ssl.certificate_authorities: ["/etc/pki/root/ca.pem"]
      setup.kibana.ssl.certificate: "/etc/pki/client/cert.pem"
      setup.kibana.ssl.key: "/etc/pki/client/cert.key
      
      配置说明
        setup.kibana.host 地址setup.kibana.username 账号setup.kibana.password 密码setup.kibana.protocol 协议setup.kibana.space.id 对指定 space 生效setup.kibana.ssl.enabled 开启 ssl

    processor(doc)

    autodiscover(doc)

    logging(doc)

常规操作
    自定义 index template (doc)自定义索引名称(doc)自定义看板(doc)给 event 添加 geoip 信息(doc)用 ingest 节点处理日期信息(doc)
模块系统
    ActiveMQ(doc),5.13.0 和 5.15.9 版本经过测试。
      配置
      metricbeat.modules:
      - module: activemq
        metricsets: ['broker', 'queue', 'topic']
        period: 10s
        hosts: ['localhost:8161']
        path: '/api/jolokia/?ignoreErrors=true&canonicalNaming=false'
        username: admin # default username
        password: admin # default password
      
      配置说明
        metricsets 传入数组,指定需要监控的组件broker(doc)queue(doc)topic(doc)
    Apache(doc),>= 2.2.31 和 >= 2.4.16的版本经过测试。
      配置
      metricbeat.modules:
      - module: apache
         metricsets: ["status"]
         period: 10s
         enabled: true
      
         # Apache hosts
         hosts: ["http://127.0.0.1"]
      
         # Path to server status. Default server-status
         #server_status_path: "server-status"
      
         # Username of hosts.  Empty by default
         #username: username
      
         # Password of hosts. Empty by default
         #password: password
      
    AWS([doc](https://www.elastic.co/guide/en/beats/metricbeat/7.10/metricbeat-module-aws.html)Azure(doc)Beats(doc)
      配置
      monitoring:
        enabled: true
        cluster_uuid: PRODUCTION_ES_CLUSTER_UUID 
        elasticsearch:
           hosts: ["https://example.com:9200", "https://example2.com:9200"] 
           api_key:  id:api_key 
           username: beats_system
           password: somepassword
           ssl.certificate_authorities: ["/etc/pki/root/ca.pem"]
           ssl.certificate: "/etc/pki/client/cert.pem"
           ssl.key: "/etc/pki/client/cert.key"
      
      配置说明
        enabled 开启监控cluster_uuid 添加集群信息之后这部分数据会被 beats 填在上报的数据包里elasticsearch 集群信息
          api_key 指定 api_key 或者 username + password 用来登陆ssl 指定证书和认证 key 等信息
    Docker(doc)Elasticsearch(doc)Etcd(doc)Google Cloud Platform(doc)Http(doc)Isito(doc)Kafka(doc)Kibana(doc)Kubernetes(doc)Linux(doc)Logstash(doc)MySql(doc)Nginx(doc)PostgreSql(doc)Prometheus(doc)RabbitMQ(doc)Redis(doc)
      配置
    metricbeat.modules:
    - module: redis
       metricsets: ["info", "keyspace"]
       enabled: true
       period: 10s
    
       # Redis hosts
       hosts: ["127.0.0.1:6379"]
       password: foo
    
      配置说明
        metricsets 传入数组配置监控维度period 延迟开启hosts 目标节点(集群)地址password 登陆密钥
    System(doc)
      配置
       metricbeat.modules:
       - module: system
          metricsets:
             - cpu             # CPU usage
             - load            # CPU load averages
             - memory          # Memory usage
             - network         # Network IO
             - process         # Per process metrics
             - process_summary # Process summary
             - uptime          # System Uptime
             - socket_summary  # Socket summary
             #- core           # Per CPU core usage
             #- diskio         # Disk IO
             #- filesystem     # File system usage for each mountpoint
             #- fsstat         # File system summary metrics
             #- raid           # Raid
             #- socket         # Sockets and connection info (linux only)
             #- service        # systemd service information
          enabled: true
          period: 10s
          processes: ['.*']
    
          # Configure the metric types that are included by these metricsets.
          cpu.metrics:  ["percentages","normalized_percentages"]  # The other available option is ticks.
          core.metrics: ["percentages"]  # The other available option is ticks.
    
      配置说明
        系统监控可以开启上面那些模块,通过在 metricsets 中配置数组实现对不同模块可以指定不同维度,通过在 x.metrics 中配置数组实现,可选的有 percentages、normalized_percentages、ticks
    Tomcat(doc)Zookeeper(doc)
自身监控
    监控上报(同 beats 模块)
安全配置

接口创建有点烦可以参考(doc),还是在 kibana 上点比较舒服

初始化账号

系统权限最少需要包括这些:

种类权限组用途
Clustermonitor接受集群信息
Clustermanage_ilm管理 ilm
Indexmetricbeat-* 的 manage通过 ilm 做别名
Indexmetricbeat-* 的 write索引的增删改

如果用的不是默认的索引名字(metricbeat-*)要指定为自定义的名字

管理员账号权限要包含这些:

Role用途
kibana_admin管理 kibana 里的各种页面
ingest_admin管理索引模板和pipeline
beats_adminbeats 相关的配置权限
监控账号

自身监控可以用 beats_system 的账号,否则需要特别创建包括以下权限:

种类权限组用途
Clustermonitor接受集群信息
Index.monitoring-beats-* 的 create_index创建监控索引
Index.monitoring-beats-* 的 create_doc往监控索引写数据

如果用 metricbeat 的话可以用 remote_monitoring_user 账号,否则需要特别创建包括以下权限:

Role用途
kibana_admin管理 kibana 里的各种页面
monitoring_user管理 kibana 里的监控功能
remote_monitoring_collector从Filebeat上采集信息
remote_monitoring_agent把监控数据发给监控集群

或者给需要看监控数据的账户赋予 monitoring_user 的权限

其他安全配置看文档(doc)

与 ES 交互的安全性

见Elasticsearch模块

与 Logstash 交互的安全性
    配置
    output.logstash:
       hosts: ["logs.mycompany.com:5044"]
       ssl.certificate_authorities: ["/etc/ca.crt"]
       ssl.certificate: "/etc/client.crt"
       ssl.key: "/etc/client.key"
    
    配置说明
      hosts 目标节点地址ssl 认证相关配置
转载请注明:文章转载自 www.mshxw.com
本文地址:https://www.mshxw.com/it/734562.html
我们一直用心在做
关于我们 文章归档 网站地图 联系我们

版权所有 (c)2021-2022 MSHXW.COM

ICP备案号:晋ICP备2021003244-6号