欢迎光临散文网 会员登陆 & 注册

使用 Filebeat+Easysearch+Console 打造日志管理平台

2023-11-18 17:24 作者:INFINI-Labs  | 我要投稿

近年来,日志管理平台越来越流行。使用日志管理平台可以实时地、统一地、方便地管理和查看日志,挖掘日志数据价值,驱动运维、运营,提升服务管理效率。

方案架构

  • Beats 是轻量级采集器,包括 Filebeat、Metricbeat 等。
  • Easysearch 是个分布式搜索引擎,提供搜集、分析、存储数据等主要功能。
  • Console 是一个可视化工具,提供可视化查询,制作报表等功能。

本文将搭建一个统一日志管理平台。使用 Filebeat 采集 OS 中的日志(其他日志大同小异),发送到 Easysearch 中。最后通过 Console 进行日志的可视化查询与分析。

操作步骤

  1. 准备工作
  • 部署 Easysearch
    • 编辑 easysearch.yml 文件,打开注释 elasticsearch.api_compatibility: true
  • 部署 Console
  1. 安装并配置 Filebeat
setup.template.name: "filebeat"
setup.template.pattern: "system-log*"
setup.template.fields: "${path.config}/fields.yml"

output.elasticsearch:
    hosts: ["localhost:9200"]
    protocol: "https"
    ssl.verification_mode: none
    username: "admin"
    password: "4ad8f8f792e81cd0a6de"
    index: "system-log"
  1. 启用 system 模块并导入 pipeline

./filebeat modules enable system  
./filebeat setup --pipelines --modules system

  1. 创建索引模板及初始索引,使用 ZSTD+SOURCE_REUSE 技术节省磁盘空间
PUT _template/system_log
{
    "order"100,
  "index_patterns": [
      "system_log*"
    ],
      "settings": {
        "index": {
          "format""7",
          "lifecycle": {
          "name""ilm_.infini_metrics-30days-retention",
          "rollover_alias""system_log"
        },
        "codec""ZSTD",
        "source_reuse"true,
        "number_of_shards""1",
        "translog": {
          "durability""async"
        }
      }
    },
    "mappings": {
      "dynamic_templates": [
        {
          "strings": {
            "mapping": {
              "ignore_above"256,
              "type""keyword"
            },
            "match_mapping_type""string"
          }
        }
      ]
    }
}

PUT system-log-00001
{
    "aliases":{
    "system-log":{
      "is_write_index":true
    }
  }
}
  1. 启动 filebeat

nohup ./filebeat -c filebeat.yml 2>&1>/dev/null &

  1. 进入 Console 查看、搜索日志  
  2. 进入 Console 创建 dashboard 进行日志分析  

使用 Filebeat+Easysearch+Console 打造日志管理平台的评论 (共 条)

分享到微博请遵守国家法律