<kbd id="afajh"><form id="afajh"></form></kbd>
<strong id="afajh"><dl id="afajh"></dl></strong>
    <del id="afajh"><form id="afajh"></form></del>
        1. <th id="afajh"><progress id="afajh"></progress></th>
          <b id="afajh"><abbr id="afajh"></abbr></b>
          <th id="afajh"><progress id="afajh"></progress></th>

          Grafana Loki 學(xué)習(xí)之踩坑記

          共 2937字,需瀏覽 6分鐘

           ·

          2022-06-13 18:20

          Grafana 出品的 loki 日志框架完美地與 kubernetes 的 label 理念結(jié)合,相對(duì)于 EFK 來說更加輕量級(jí),非常適合不需要日志聚合的場(chǎng)景。目前新上集群考慮都采用 loki 做為基礎(chǔ)工具,直接在 grafana 中展示,在這里記錄下使用 Loki 踩過的一些坑。

          踩過的坑

          LOKI 啟動(dòng)時(shí)提示 panic: invalid page type: 11:10

          原因: 對(duì)應(yīng)的 index table 文件已經(jīng)損壞

          解決: 刪除相應(yīng)的 index 文件即可解決

          日志的 label 不對(duì)

          原因: promtail 中的 scrape_config 存在問題.

          參考: https://izsk.me/2022/05/15/Loki-log-with-wrong-labels/

          grafana 中開啟實(shí)時(shí)日志時(shí)提示 Query error

          原因: 官方的解釋是 Note that live tailing relies on two websocket connections: one between the browser and the Grafana server, and another between the Grafana server and the Loki server. If you run any reverse proxies, please configure them accordingly.

          也就是說,如果在 web 與 grafana,grafana 與 loki 之間存在如 nginx 類的 proxy,則需要開啟 websocket 特性,恰好作者的 grafana 是在 nginx 后的

          解決: nginx 添加 websocket 配置, [詳見] https://www.nginx.com/blog/websocket-nginx/

          參考: https://github.com/grafana/grafana/blob/b5d8cb25e18fc73f37b3546246363464c9298684/docs/sources/features/datasources/loki.md

          Loki: file size too small\nerror creating index client

          解決: 刪除 loki 的持久化目錄下的 boltdb-shipper-active/index_18xxx 目錄

          參考: https://github.com/grafana/loki/issues/3219

          protail: context deadline exceeded

          原因: promtail 無法連接 loki 所致

          promtail cpu 使用過高

          原因: 由于集群中存在大量的 job 類 pod,這會(huì)對(duì) loki 的服務(wù)發(fā)現(xiàn)會(huì)有很大的壓力,需要調(diào)整 promtail 的配置,查看官方的 issue,后續(xù)可能會(huì)將 ds 由 promtail 轉(zhuǎn)到服務(wù)端來做,promtail 需要調(diào)整的配置主要為

          target_config:
            sync_period: 30s
          positions:
            filename: /run/promtail/positions.yaml
            sync_period: 30s

          將 sync_period 由默認(rèn)的 10s 換成 30s

          可以使用以下的命令獲取到 pprof 文件分析性能

          curl localhost:3100/debug/pprof/profile\?seconds\=20

          參考: https://github.com/grafana/loki/issues/1315

          Maximum active stream limit exceeded

          原因:同下,需要調(diào)整 limit config 中的 max_streams_per_user, 設(shè)置為 0 即可

          server returned HTTP status 429 Too Many Requests

          原因: limit config 中的參數(shù): ingestion_burst_size 默認(rèn)值太小,調(diào)整即可

          參考: https://github.com/grafana/loki/issues/1923

          Please verify permissions

          原因: 這條其實(shí)是 warn,不影響 promtail 的正常工作,如果調(diào)整過日志的路徑的話要確認(rèn) promtail 掛載的路徑是否正常

          loki: invalid schema config

          原因: loki 的配置文件格式錯(cuò)誤.

          promtail: too many open files

          原因: /var/log/pods 下面的文件數(shù)量太多,導(dǎo)致超過內(nèi)核參數(shù)(fs.inotify.max_user_instances)設(shè)置配置.

          解決

          # 先查看當(dāng)前機(jī)器設(shè)置的配置
          cat /proc/sys/fs/inotify/max_user_instances
          # 再查看promtail啟動(dòng)時(shí)watch的文件數(shù)
          cat /run/promtail/positions.yaml | wc -l
          # 如果這個(gè)值比max_user_instances要大,則會(huì)出現(xiàn)上面的錯(cuò)誤,可以通過修改內(nèi)核參數(shù)進(jìn)行調(diào)整
          sysctl -w fs.inotify.max_user_instances=1024
          # 生效
          sysctl -p

          參考: https://github.com/grafana/loki/issues/1153

          promtail: no such file ro directory

          原因:promtail daemonset 啟動(dòng)時(shí)會(huì)自動(dòng)掛載好幾個(gè) hostpath,如果 docker containers 的配置調(diào)整過,則需要 volume 跟 volumemount 都需要對(duì)應(yīng)上。

          參考文章

          • https://github.com/grafana/loki/issues/429
          • https://github.com/grafana/loki/issues/3219
          • https://github.com/grafana/loki/issues/1153
          • https://github.com/grafana/loki/issues/1923
          • https://blog.csdn.net/weixin_44997607/article/details/108419144
          • https://github.com/grafana/loki/issues/1315
          • https://www.nginx.com/blog/websocket-nginx/

          原文地址:https://izsk.me/2022/05/15/Loki-Prombles

          瀏覽 312
          點(diǎn)贊
          評(píng)論
          收藏
          分享

          手機(jī)掃一掃分享

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

          手機(jī)掃一掃分享

          分享
          舉報(bào)
          <kbd id="afajh"><form id="afajh"></form></kbd>
          <strong id="afajh"><dl id="afajh"></dl></strong>
            <del id="afajh"><form id="afajh"></form></del>
                1. <th id="afajh"><progress id="afajh"></progress></th>
                  <b id="afajh"><abbr id="afajh"></abbr></b>
                  <th id="afajh"><progress id="afajh"></progress></th>
                  亚欧精品久久久久久久久久 | 欧美一区二区三区婷婷五月 | www.蜜芽av | 亚洲日韩免费一级无码毛片 | 黑人嫖中国女精品视频 |