天天看點

使用 ELK 檢視 Ceph 讀寫速度(二)

上一篇 使用 ELK 檢視 Ceph 讀寫速度(一)

裡,我們通過 ceph monit api 接口,抓取到了需要的資料。接下來,我們就要把這些資料圖形化展示出來了。

首先我們使用還在實驗階段的 Visual Builder 建立一個曲線圖。進入 Visualize 頁面,點選 + 号建立一個 Visual Builder。

使用 ELK 檢視 Ceph 讀寫速度(二)
然後按照下圖所示,分 3 部分填寫。你就能得到最上面的曲線圖了。
使用 ELK 檢視 Ceph 讀寫速度(二)
使用 ELK 檢視 Ceph 讀寫速度(二)
使用 ELK 檢視 Ceph 讀寫速度(二)
然後儲存這個 visual 面闆。接着建立一個 Dashboard,把建好的 visual 面闆加入。觀察效果,發現有斷流現象。
使用 ELK 檢視 Ceph 讀寫速度(二)
通過檢視我們上一篇裡建立的 search,我發現了有資料為空的記錄。再通過檢視日志原文,發現原來是因為 ceph 接口傳回的資料裡,read 機關值有 kB/s、B/s 和 MB/s 三種。我的 logstash filter 隻對應了其中一種,自然就比對缺失了。是以,我們改進一下 filter。

filter {
  if "ceph-pg-stat" in [tags] {
  
    grok {
      match => {
        "message" => [
          "%{GREEDYDATA}avail; %{INT:[ceph][cluster][read]} kB\/s rd, %{INT:[ceph][cluster][write]} kB\/s wr, %{INT:[ceph][cluster][op]} op\/s"
        ]
      }
      remove_field => "message"
    }
    
    grok {
      match => {
        "message" => [
          "%{GREEDYDATA}avail; %{INT:[ceph][cluster][read]} B\/s rd, %{INT:[ceph][cluster][write]} kB\/s wr, %{INT:[ceph][cluster][op]} op\/s"
        ]
      }
      add_tag => ["low_speed"]
      remove_field => "message"
    }
    # Convert B/s to kB/s
    if "low_speed" in [tags] {
      ruby {
        code => "event['ceph.cluster.read'] = Integer(event['ceph.cluster.read'].gsub(',','') / 1024)"
        remove_tag => ["low_speed"]
      }
    }
    
    grok {
      match => {
        "message" => [
          "%{GREEDYDATA}avail; %{INT:[ceph][cluster][read]} MB\/s rd, %{INT:[ceph][cluster][write]} kB\/s wr, %{INT:[ceph][cluster][op]} op\/s"
        ]
      }
      add_tag => ["high_speed"]
      remove_field => "message"
    }
    # Convert MB/s to kB/s
    if "high_speed" in [tags] {
      ruby {
        code => "event['ceph.cluster.read'] = Integer(event['ceph.cluster.read'].gsub(',','') * 1024)"
        remove_tag => ["high_speed"]
      }
    }
    mutate {
      convert => { "[ceph][cluster][read]" => "integer" }
      convert => { "[ceph][cluster][write]" => "integer" }
      convert => { "[ceph][cluster][op]" => "integer" }
    }
    
  }
}           

問題就解決啦。大家舉一反三,可以做出以下這樣的 dashboard。

使用 ELK 檢視 Ceph 讀寫速度(二)

繼續閱讀