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

指标监控

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

配置启动

  1. 安装
  2. 修改相关配置
    1. 输出到 ES
        output.elasticsearch:
           hosts: ["myEShost:9200"]
           username: "metricbeat_internal"
           password: "YOUR_PASSWORD" 
      
    2. (可选)初始化 Kibana(如果 KibanaES 在同一集群可跳过)
        setup.kibana:
           host: "mykibanahost:5601" 
           username: "my_kibana_user"  
           password: "{pwd}"
      
  3. 开启需要的采集模块
    ./metricbeat modules enble ${module1} ${module2}
    
  4. 在集群中初始化采集模块相关配置
    ./metricbeat setup -e
    
  5. 启动 metricbeat
    1. 给配置文件赋予权限
      sudo chown root metricbeat.yml 
      sudo chown root modules.d/system.yml
      
    2. 启动
      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

常见命令

  1. 帮助(help

    ./metricbeat -h
    
    ./metricbeat help export
    
  2. 导出(export),可以导出配置和看板等

    ./metricbeat export config --es.version 7.10.2
    
    ./metricbeat export dashboard --id="xx" > dashboard.json
    
  3. keystore,管理密钥相关配置,doc

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

    ./metricbeat modules list
    
    ./metricbeat modules enable mysql
    
  5. 初始化(setup),在目标集群里初始化对应的模板、pipeline、看板等,doc

    ./metricbeat setup -e
    
    ./metricbeat setup --dashboards -e
    

常规配置

  1. 示例文件 (doc

  2. 全局配置

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

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

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

    1. 主要需要关注的:
      1. Elasticsearch Servicedoc
      2. Elasticsearch(doc)
      3. Logstashdoc
      4. Kafkadoc
      5. Filedoc
      6. Consoledoc
  6. SSLdoc

    1. 配置开启
      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"
      
    2. 配置说明
      1. enabled 是否开启
      2. certificate_authorities 认证证书,支持路径数组,也可以直接把证书在里面
      3. certificate 认证信息,支持路径,也可以直接贴在里面
      4. key 密钥,支持路径,也可以直接贴在里面
      5. verification_mode认证模式,默认 full,同时支持 certificatenone
  7. ilmdoc

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

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

    1. 配置
      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
      
    2. 配置说明
      1. setup.kibana.host 地址
      2. setup.kibana.username 账号
      3. setup.kibana.password 密码
      4. setup.kibana.protocol 协议
      5. setup.kibana.space.id 对指定 space 生效
      6. setup.kibana.ssl.enabled 开启 ssl
  10. processordoc

  11. autodiscoverdoc

  12. loggingdoc

常规操作

  1. 自定义 index templatedoc
  2. 自定义索引名称(doc
  3. 自定义看板(doc
  4. event 添加 geoip 信息(doc
  5. ingest 节点处理日期信息(doc

模块系统

  1. ActiveMQdoc),5.13.05.15.9 版本经过测试。
    1. 配置
      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
      
    2. 配置说明
      1. metricsets 传入数组,指定需要监控的组件
      2. brokerdoc
      3. queuedoc
      4. topicdoc
  2. Apachedoc),>= 2.2.31>= 2.4.16的版本经过测试。
    1. 配置
      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
      
  3. AWS([doc](https://www.elastic.co/guide/en/beats/metricbeat/7.10/metricbeat-module-aws.html)
  4. Azuredoc
  5. Beatsdoc
    1. 配置
      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"
      
    2. 配置说明
      1. enabled 开启监控
      2. cluster_uuid 添加集群信息之后这部分数据会被 beats 填在上报的数据包里
      3. elasticsearch 集群信息
        1. api_key 指定 api_key 或者 username + password 用来登陆
        2. ssl 指定证书和认证 key 等信息
  6. Dockerdoc
  7. Elasticsearchdoc
  8. Etcddoc
  9. Google Cloud Platformdoc
  10. Httpdoc
  11. Isitodoc
  12. Kafkadoc
  13. Kibanadoc
  14. Kubernetesdoc
  15. Linuxdoc
  16. Logstashdoc
  17. MySqldoc
  18. Nginxdoc
  19. PostgreSqldoc
  20. Prometheusdoc
  21. RabbitMQdoc
  22. Redisdoc
    1. 配置
    metricbeat.modules:
    - module: redis
       metricsets: ["info", "keyspace"]
       enabled: true
       period: 10s
    
       # Redis hosts
       hosts: ["127.0.0.1:6379"]
       password: foo
    
    1. 配置说明
      1. metricsets 传入数组配置监控维度
      2. period 延迟开启
      3. hosts 目标节点(集群)地址
      4. password 登陆密钥
  23. Systemdoc
    1. 配置
       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.
    
    1. 配置说明
      1. 系统监控可以开启上面那些模块,通过在 metricsets 中配置数组实现
      2. 对不同模块可以指定不同维度,通过在 x.metrics 中配置数组实现,可选的有 percentagesnormalized_percentagesticks
  24. Tomcatdoc
  25. Zookeeperdoc

自身监控

  1. 监控上报(同 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_collectorFilebeat上采集信息
remote_monitoring_agent把监控数据发给监控集群

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

其他安全配置看文档(doc

与 ES 交互的安全性

Elasticsearch模块

与 Logstash 交互的安全性
  1. 配置
    output.logstash:
       hosts: ["logs.mycompany.com:5044"]
       ssl.certificate_authorities: ["/etc/ca.crt"]
       ssl.certificate: "/etc/client.crt"
       ssl.key: "/etc/client.key"
    
  2. 配置说明
    1. hosts 目标节点地址
    2. ssl 认证相关配置
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值