天天看點

prometheus監控_使用 prometheus 監控clickhouse 叢集

一 前言

本文介紹 采用clickhouse-exporter + grafana + prometheus 搭建監控clickhouse 單節點和叢集的監控體系。

什麼是 prometheus ,可以從這裡了解 。

二 部署exporter

擷取代碼并編譯

因為生産環境的系統是基于Linux不能直接通路外網,故在自己的 mac 系統先編譯成二進制。然後拷貝到生産環境。

在mac上編譯 clickhouse_exporter,

在下載下傳到源代碼目錄。

cd $GO_PATH/src/github.com/Percona-Lab
GO111MODULE=off `CGO_ENABLED`=0 GOOS=linux GOARCH=amd64 go build clickhouse_exporter.go
           

編譯成功會看到 二進制檔案

$ ./clickhouse_exporter  -h
Usage of ./clickhouse_exporter:
  -insecure
        Ignore server certificate if using https (default true)
  -log.level value
        Only log messages with the given severity or above. Valid levels: [debug, info, warn, error, fatal, panic].
  -scrape_uri string
        URI to clickhouse http endpoint (default "http://localhost:8123/")
  -telemetry.address string
        Address on which to expose metrics. (default ":9116")
  -telemetry.endpoint string
        Path under which to expose metrics. (default "/metrics")
           

配置比較簡單 就是指定 

scrape_uri

=

clickhouse_server_ip

:port, 

啟動exporter

./clickhouse_exporter -scrape_uri=http://clickhouse_server_ip:8123/ -log.level=info
           

在exporter機器上檢視是否能擷取到clickhouse的資料

prometheus監控_使用 prometheus 監控clickhouse 叢集

成功。。

三 配置prometheus

修改prometheus.yml檔案,targets 指定 clickhouse_exporter的ip位址和端口号 

- job_name: 'clickhouse_exporter'
    scrape_interval: 10s
    static_configs:
      - targets:
        - "clickhouse_exporter_ip:9116"
           

修改完配置檔案 重新加載 

curl 'http://localhost:9090/-/reload' -X POST

監控多個clickhouse節點

當然如果監控多個clickhouse叢集節點要怎麼處理?目前測試的 clickhouse_exporter 還不支援 ,要重寫接受參數的處理邏輯。

或者有知道的朋友怎麼操作 可以留言交流。

四 配置grafna圖形

從 https://grafana.com/grafana/dashboards/882 擷取clickhouse 的監控采集資料模闆 ,導入模闆 選擇prometheus資料源,監控展示

prometheus監控_使用 prometheus 監控clickhouse 叢集

五 小結

本文算是淺顯的介紹了利用clickhouse-exporter + grafana + prometheus部署clickhouse的監控。看了clickhouse的性能展示模闆還是比較粗糙,如果有需要更細粒度的展示 clickhouse 的叢集狀态,可以基于監控的metrics 去配置更豐富的名額。

have fun with ClickHouse  ^_^

-The End-

本公衆号長期關注于資料庫技術以及性能優化,故障案例分析,資料庫運維技術知識分享,個人成長和自我管理等主題,歡迎掃碼關注。

prometheus監控_使用 prometheus 監控clickhouse 叢集

繼續閱讀