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


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

    方案架构

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

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

    操作步骤

    1. 准备工作
      • 部署 Easysearch
        • 编辑 easysearch.yml 文件,打开注释 elasticsearch.api_compatibility: true
      • 部署 Console
    2. 安装并配置 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
    • 2
    • 3
    • 4
    • 5
    • 6
    • 7
    • 8
    • 9
    • 10
    • 11
    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
    • 2
    • 3
    • 4
    • 5
    • 6
    • 7
    • 8
    • 9
    • 10
    • 11
    • 12
    • 13
    • 14
    • 15
    • 16
    • 17
    • 18
    • 19
    • 20
    • 21
    • 22
    • 23
    • 24
    • 25
    • 26
    • 27
    • 28
    • 29
    • 30
    • 31
    • 32
    • 33
    • 34
    • 35
    • 36
    • 37
    • 38
    • 39
    • 40
    • 41
    • 42
    • 43
    • 44
    1. 启动 filebeat

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

    1. 进入 Console 查看、搜索日志
    2. 进入 Console 创建 dashboard 进行日志分析
  • 相关阅读:
    详细介绍如何使用YOLOV8和KerasCV进行高效物体检测
    Web 中间件怎么玩?
    关于三极管的认知
    【面试高高手】—— Redis
    WebGoat通关攻略之 SQL Injection (intro)
    STM32中事件标志位与中断标志位
    网页游戏的开发框架
    解决Git推送错误:Updates were rejected的完整指南
    压缩sql server日志的方法
    UNIAPP实战项目笔记34 购物车的单选和全选单选联动
  • 原文地址:https://blog.csdn.net/infinilabs/article/details/134480494