cortext是prometheus的多租戶解決方案,目前在cncf 沙箱孵化,以下是一個簡單的試用
注意因為golang 包的問題,而且以下依賴的幾個項目都是基於go module 的所以使用了goproxy 配置,具體配置為:
export GOPROXY=https://goproxy.cn/,此處運行的是單實例模式
單實例,單進程運行
- clone cortex 代碼
git clone https://github.com/cortexproject/cortex.git
- 構建
cd cortex
go build ./cmd/cortex
- 啟動
./cortex -config.file=./docs/single-process-config.yaml
- prometheus 運行
也是基於源碼構建,同時需要添加remote_write
clone prometheus 代碼
git clone https://github.com/prometheus/prometheus
構建prometheus
cd prometheus
go build ./cmd/prometheus
修改demo 配置
documentation/examples/prometheus.yml 添加以下內容
remote_write:
- url: http://localhost:9009/api/prom/push
- 運行
./prometheus --config.file=./documentation/examples/prometheus.yml
- 運行grafana dashboard工具
docker 啟動
docker run -d --name=grafana -p 3000:3000 grafana/grafana
添加promethesu datasource
注意修改為自己的docker 主機ip
http://host.docker.internal:9009/api/prom
說明:為了對比,最好也添加下原生prometheus server
運行效果
- 通過grafana 查詢對比
- 數據存儲效果
demo 數據存放在/tmp/cortex 內容如下:
說明
以上是一個簡單的單機運行試用,后邊會試用docker-compose 運行多實例
參考資料
https://github.com/cortexproject/cortex/blob/master/docs/getting_started.md