1. ES06# Filebeat采集原理與監(jiān)控指標(biāo)梳理

        共 8022字,需瀏覽 17分鐘

         ·

        2022-05-10 15:53

        當(dāng)Filebeat作為日志采集的agent鋪開時(shí),對其自身agent的監(jiān)控以確保穩(wěn)定就尤為的重要,有幾種方式監(jiān)控agent運(yùn)行。

        • 第一種 filebeat自己將監(jiān)控埋點(diǎn)上報(bào)
        • 第二種 filebeat暴露埋點(diǎn)接口,另外一個(gè)agent定時(shí)采集后上報(bào)

        第二種能夠監(jiān)測filebeat的進(jìn)程狀況,例如官方提供的Metricbeat,也可以自己實(shí)現(xiàn)agent上報(bào)監(jiān)控指標(biāo)。本文就其如何監(jiān)控Filebeat以及指標(biāo)含義進(jìn)行梳理,主要內(nèi)容有:

        • 一、filebeat日志采集原理
        • 二、filebeat暴露endpoint
        • 三、beat監(jiān)控指標(biāo)
        • 四、filebeat監(jiān)控指標(biāo)
        • 五、libbeat監(jiān)控指標(biāo)
        • 六、監(jiān)控指標(biāo)完整示例
        一、filebeat日志采集原理

        filebeat采集原理如下圖所示,數(shù)據(jù)流從左到右流轉(zhuǎn)。


        組件描述:

        Input:負(fù)責(zé)輸入源,每啟動(dòng)一個(gè)文件會(huì)創(chuàng)建一個(gè)Harvester負(fù)責(zé)讀取

        Filebeat.Harvester:負(fù)責(zé)文件數(shù)據(jù)的讀取

        Filebeat.Registrar:負(fù)責(zé)記錄文件以及對應(yīng)的偏移量,記錄在registry/filebeat/log.json中,格式如下所示,filebeat啟動(dòng)時(shí)會(huì)讀取該文件

        {"k":"filebeat::logs::native::4349261-16777229","v":{"id":"native::4349261-16777229","prev_id":"","source":"/Users/admin/logs/csp/sentinel-server.log","offset":1150,"type":"log","identifier_name":"native","timestamp":[2062583329080,1648206113],"ttl":-1,"FileStateOS":{"inode":4349261,"device":16777229}}}

        Libbeat.Pipeline:負(fù)責(zé)管理Harvester的寫入、緩存、輸出等,queue事件隊(duì)列(緩存or磁盤),acker輸出后的確認(rèn)回調(diào)

        二、filebeat暴露endpoint

        1.HTTP endpoint

        在filebeat.yml文件中開啟http.enabled,默認(rèn)端口為5066,本文將其修改成了5067。

        #Enable?the?HTTP?endpoint?to?allow?external?collection?of?monitoring?data
        http.enabled:?true
        http.port:?5067

        2.filebeat基本信息

        請求命令

        http://localhost:5067/?pretty

        返回示例

        {
        ??"beat":?"filebeat",
        ??"hostname":?"M-C02GL1NTQ05P",
        ??"name":?"M-C02GL1NTQ05P",
        ??"uuid":?"d9823622-46a6-4f4d-8dda-f2efeee82e35",
        ??"version":?"7.15.2"
        }

        指標(biāo)說明

        指標(biāo)說明
        beatbeat的類型,本文為filebeat
        hostname主機(jī)名稱
        uuidfilebeat的uuid
        versionfilebeat的版本

        另外下面命令返回了filebeat的眾多指標(biāo)信息,下文中根據(jù)不同的類型分拆梳理走查。

        http://localhost:5067/stats?pretty

        三、beat監(jiān)控指標(biāo)

        beat為通用模塊,filebeat繼承該模塊,側(cè)重于整體概覽。主要包括:基本信息、CPU運(yùn)行狀態(tài)信息、緩存指標(biāo)信息、運(yùn)行時(shí)指標(biāo)。

        1.基本信息

        返回示例

        "info":?{
        ??????"ephemeral_id":?"7ab1d8ba-098d-46a8-a116-bfc350493f40",
        ??????"uptime":?{
        ????????"ms":?623789
        ??????},
        ??????"version":?"7.15.2"
        ?}

        指標(biāo)說明

        指標(biāo)說明
        ephemeral_id臨時(shí)ID用于標(biāo)識此agent,在重啟后會(huì)變化
        uptimeagent的運(yùn)行時(shí)間
        versionagent的版本信息

        2.CPU運(yùn)行狀態(tài)

        返回示例

        "cpu":?{
        ??????"system":?{
        ????????"ticks":?17,
        ????????"time":?{
        ??????????"ms":?737
        ????????}
        ??????},
        ??????"total":?{
        ????????"ticks":?34,
        ????????"time":?{
        ??????????"ms":?1464
        ????????},
        ????????"value":?34
        ??????},
        ??????"user":?{
        ????????"ticks":?17,
        ????????"time":?{
        ??????????"ms":?727
        ????????}
        ??????}
        ?}

        指標(biāo)說明

        指標(biāo)說明
        system.ticks運(yùn)行CPU處于系統(tǒng)狀態(tài)的時(shí)間
        user.ticks運(yùn)行CPU處于用戶狀態(tài)的時(shí)間
        total.ticks運(yùn)行CPU處于系統(tǒng)狀態(tài)和用戶狀態(tài)總的時(shí)間

        3.緩存指標(biāo)

        返回示例

        "memstats":?{
        ??"gc_next":?23418608,
        ??"memory_alloc":?16693968,
        ??"memory_sys":?76366856,
        ??"memory_total":?181068824,
        ??"rss":?46481408
        }

        指標(biāo)說明

        指標(biāo)說明
        gc_next下一次GC目標(biāo)堆的大小
        memory_allocGo語言堆空間分配的字節(jié)數(shù)
        memory_sys服務(wù)當(dāng)前使用系統(tǒng)的內(nèi)存大小
        memory_total服務(wù)運(yùn)行至今總共分配的堆內(nèi)存大小(只遞增)
        rssResident Set Size(常駐內(nèi)存大?。┍硎具M(jìn)程使用了多少內(nèi)存

        4.運(yùn)行時(shí)指標(biāo)

        返回示例

        "runtime":?{
        ??"goroutines":?31
        }

        指標(biāo)說明

        指標(biāo)說明
        goroutines運(yùn)行時(shí)調(diào)度管理“線程池”大小

        四、filebeat監(jiān)控指標(biāo)

        1.events指標(biāo)

        返回示例

        "events":?{
        ??????"active":?0,
        ??????"added":?3,
        ??????"done":?3
        ????}

        指標(biāo)說明

        指標(biāo)說明
        active正在活動(dòng)事件的數(shù)量
        added已添加事件的數(shù)量
        done已完成事件的數(shù)量

        備注:通過events了解filebeat的吞吐情況。

        2.harvester指標(biāo)

        返回示例

        "harvester":?{
        ??????"closed":?0,
        ??????"open_files":?0,
        ??????"running":?0,
        ??????"skipped":?0,
        ??????"started":?0
        ????}

        指標(biāo)說明

        指標(biāo)說明
        closedharvester已關(guān)閉的數(shù)量
        open_files已打開的文件數(shù)量
        running正在harvester的數(shù)量
        skippedharvester已忽略的數(shù)量
        startedharvester已啟動(dòng)的數(shù)量

        備注:每個(gè)文件都會(huì)通過一個(gè)harvester讀取,通過harvester監(jiān)控讀取文件數(shù)量情況。

        3.input指標(biāo)

        返回示例

        "input":?{
        ??????"log":?{
        ????????"files":?{
        ??????????"renamed":?0,
        ??????????"truncated":?0
        ????????}
        ??????},
        ??????"netflow":?{
        ????????"flows":?0,
        ????????"packets":?{
        ??????????"dropped":?0,
        ??????????"received":?0
        ????????}
        ??????}

        指標(biāo)說明

        指標(biāo)說明
        files.renamed被改名文件的數(shù)量
        files.truncated被截?cái)辔募臄?shù)量
        netflow.flowsIP網(wǎng)絡(luò)流量統(tǒng)計(jì)
        packets.dropped丟棄的分組(packets)數(shù)量
        packets.received接受的分組(packets)數(shù)量

        備注:每個(gè)文件都會(huì)通過一個(gè)harvester讀取,通過harvester監(jiān)控讀取文件數(shù)量情況,netflow網(wǎng)絡(luò)數(shù)據(jù)包分析工具。


        五、libbeat監(jiān)控指標(biāo)

        libbeat為公共模塊,filebeat繼承了該模塊??梢詏utput的速率、pipeline中隊(duì)列積壓以及registrar記錄位移情況。

        1.config指標(biāo)

        返回示例

        "config":?{
        ??????"module":?{
        ????????"running":?0,
        ????????"starts":?0,
        ????????"stops":?0
        ??????},
        ??????"reloads":?1,
        ??????"scans":?62
        ????}

        指標(biāo)說明

        指標(biāo)說明
        module.running正在運(yùn)行組件的數(shù)量
        module.starts已啟動(dòng)組件的數(shù)量
        module.stops已停止組件的數(shù)量
        reloads加載配置文件的數(shù)量
        scans掃描配置文件的數(shù)量

        2.output指標(biāo)

        返回示例

        "output":?{
        ??????"events":?{
        ????????"acked":?0,
        ????????"active":?0,
        ????????"batches":?0,
        ????????"dropped":?0,
        ????????"duplicates":?0,
        ????????"failed":?0,
        ????????"toomany":?0,
        ????????"total":?0
        ??????},
        ??????"read":?{
        ????????"bytes":?0,
        ????????"errors":?0
        ??????},
        ??????"type":?"elasticsearch",
        ??????"write":?{
        ????????"bytes":?0,
        ????????"errors":?0
        ??????}
        ????}

        指標(biāo)說明

        指標(biāo)說明
        events.acked確認(rèn)事件數(shù)量
        events.active活動(dòng)事件數(shù)量
        events.dropped丟棄事件數(shù)量
        events.failed失敗事件數(shù)量
        read.bytes讀入的字節(jié)數(shù)
        write.bytes寫出的字節(jié)數(shù)

        3.pipeline指標(biāo)

        返回示例

        "pipeline":?{
        ??????"clients":?1,
        ??????"events":?{
        ????????"active":?0,
        ????????"dropped":?0,
        ????????"failed":?0,
        ????????"filtered":?3,
        ????????"published":?0,
        ????????"retry":?0,
        ????????"total":?3
        ??????},
        ??????"queue":?{
        ????????"acked":?0,
        ????????"max_events":?4096
        ??????}
        ????}

        指標(biāo)說明

        指標(biāo)說明
        clients連接到pipeline的client數(shù)量
        queue.ackedqueue中已被output確認(rèn)的數(shù)量
        queue.max_eventsqueue中存儲事件的最大數(shù)量

        備注:Filebeat使用內(nèi)部queue存儲publishing前的事件,這些事件會(huì)被outputs消費(fèi)。

        4.registrar指標(biāo)

        返回示例

        "registrar":?{
        ????"states":?{
        ??????"cleanup":?0,
        ??????"current":?3,
        ??????"update":?3
        ????},
        ????"writes":?{
        ??????"fail":?0,
        ??????"success":?3,
        ??????"total":?3
        ????}
        ??}

        指標(biāo)說明

        指標(biāo)說明
        states.cleanup被清理registrar的數(shù)量
        states.current正在運(yùn)行registrar的數(shù)量
        states.update已更新registrar的數(shù)量
        writes.fail寫入registry文件失敗的數(shù)量
        writes.success寫入registry文件成功的數(shù)量

        備注:registrar會(huì)記錄日志文件采集的位移。

        5.CPU負(fù)載指標(biāo)

        返回示例

        "system":?{
        ????"cpu":?{
        ??????"cores":?8
        ????},
        ????"load":?{
        ??????"1":?2.749,
        ??????"15":?2.5459,
        ??????"5":?2.5659,
        ??????"norm":?{
        ????????"1":?0.3436,
        ????????"15":?0.3182,
        ????????"5":?0.3207
        ??????}
        ????}

        指標(biāo)說明

        指標(biāo)說明
        coresCPU核數(shù)
        loadCPU負(fù)載

        六、監(jiān)控指標(biāo)完整示例

        指標(biāo)端點(diǎn)

        http://localhost:5067/stats?pretty

        返回示例

        {
        ??"beat":?{
        ????"cpu":?{
        ??????"system":?{
        ????????"ticks":?17,
        ????????"time":?{
        ??????????"ms":?737
        ????????}
        ??????},
        ??????"total":?{
        ????????"ticks":?34,
        ????????"time":?{
        ??????????"ms":?1464
        ????????},
        ????????"value":?34
        ??????},
        ??????"user":?{
        ????????"ticks":?17,
        ????????"time":?{
        ??????????"ms":?727
        ????????}
        ??????}
        ????},
        ????"info":?{
        ??????"ephemeral_id":?"7ab1d8ba-098d-46a8-a116-bfc350493f40",
        ??????"uptime":?{
        ????????"ms":?623789
        ??????},
        ??????"version":?"7.15.2"
        ????},
        ????"memstats":?{
        ??????"gc_next":?23418608,
        ??????"memory_alloc":?16693968,
        ??????"memory_sys":?76366856,
        ??????"memory_total":?181068824,
        ??????"rss":?46481408
        ????},
        ????"runtime":?{
        ??????"goroutines":?31
        ????}
        ??},
        ??"filebeat":?{
        ????"events":?{
        ??????"active":?0,
        ??????"added":?3,
        ??????"done":?3
        ????},
        ????"harvester":?{
        ??????"closed":?0,
        ??????"open_files":?0,
        ??????"running":?0,
        ??????"skipped":?0,
        ??????"started":?0
        ????},
        ????"input":?{
        ??????"log":?{
        ????????"files":?{
        ??????????"renamed":?0,
        ??????????"truncated":?0
        ????????}
        ??????},
        ??????"netflow":?{
        ????????"flows":?0,
        ????????"packets":?{
        ??????????"dropped":?0,
        ??????????"received":?0
        ????????}
        ??????}
        ????}
        ??},
        ??"libbeat":?{
        ????"config":?{
        ??????"module":?{
        ????????"running":?0,
        ????????"starts":?0,
        ????????"stops":?0
        ??????},
        ??????"reloads":?1,
        ??????"scans":?62
        ????},
        ????"output":?{
        ??????"events":?{
        ????????"acked":?0,
        ????????"active":?0,
        ????????"batches":?0,
        ????????"dropped":?0,
        ????????"duplicates":?0,
        ????????"failed":?0,
        ????????"toomany":?0,
        ????????"total":?0
        ??????},
        ??????"read":?{
        ????????"bytes":?0,
        ????????"errors":?0
        ??????},
        ??????"type":?"elasticsearch",
        ??????"write":?{
        ????????"bytes":?0,
        ????????"errors":?0
        ??????}
        ????},
        ????"pipeline":?{
        ??????"clients":?1,
        ??????"events":?{
        ????????"active":?0,
        ????????"dropped":?0,
        ????????"failed":?0,
        ????????"filtered":?3,
        ????????"published":?0,
        ????????"retry":?0,
        ????????"total":?3
        ??????},
        ??????"queue":?{
        ????????"acked":?0,
        ????????"max_events":?4096
        ??????}
        ????}
        ??},
        ??"registrar":?{
        ????"states":?{
        ??????"cleanup":?0,
        ??????"current":?3,
        ??????"update":?3
        ????},
        ????"writes":?{
        ??????"fail":?0,
        ??????"success":?3,
        ??????"total":?3
        ????}
        ??},
        ??"system":?{
        ????"cpu":?{
        ??????"cores":?8
        ????},
        ????"load":?{
        ??????"1":?2.749,
        ??????"15":?2.5459,
        ??????"5":?2.5659,
        ??????"norm":?{
        ????????"1":?0.3436,
        ????????"15":?0.3182,
        ????????"5":?0.3207
        ??????}
        ????}
        ??}
        }

        備注:官方參考文檔

        https://www.elastic.co/guide/en/beats/filebeat/current/http-endpoint.html

        #?Monitor?Filebeat
        https://www.elastic.co/guide/en/beats/filebeat/current/monitoring.html#monitoring

        #?Filebeat?internal?collection
        https://www.elastic.co/guide/en/beats/filebeat/current/configuration-monitor.html

        #?Metricbeat?collection
        https://www.elastic.co/guide/en/beats/filebeat/current/monitoring-metricbeat-collection.html
        瀏覽 98
        點(diǎn)贊
        評論
        收藏
        分享

        手機(jī)掃一掃分享

        分享
        舉報(bào)
        評論
        圖片
        表情
        推薦
        點(diǎn)贊
        評論
        收藏
        分享

        手機(jī)掃一掃分享

        分享
        舉報(bào)
          
          

            1. 男女激情视频 | 欧美另类老妇 | 爱搞在线观看 | 国产69操逼| 竹内纱里奈被黑人狂躁 |