- prometheus: monitoring system and time series database.
- grafana: The open and composable observability and data visualization platform. Visualize metrics, logs, and traces from multiple sources like Prometheus, Loki, Elasticsearch, InfluxDB, Postgres and many more.
公司環境都是使用 docker 的安裝方式安裝
default login info admin/admin
docker run -d -p 3000:3000 --name grafana grafana/grafana:6.5.0
Exporter for machine metrics
在需要監控的主機裝就好了
docker run -d \
--net="host" \
--pid="host" \
--name node-exporter \
-v "/:/host:ro,rslave" \
quay.io/prometheus/node-exporter:latest \
--path.rootfs=/host
先設定好 prometheus config
prometheus/prometheus.yml
scrape_configs:
# The job name is added as a label `job=<job_name>` to any timeseries scraped from this config.
# 監控的 metric 位置,指向 node-exporter 安裝的主機
- job_name: 'prometheus'
static_configs:
- targets: ['10.110.86.130:9100']
labels:
instance: 'local-01'
platform: 'sh'
安裝 prometheus
docker run -d \
-p 9090:9090 \
-v /home/blockchain/prometheus/prometheus.yml:/etc/prometheus/prometheus.yml \
--name prometheus \
prom/prometheus
http://10.110.86.130:9090
這邊紀錄了所以收集來的監控資訊
http://10.110.86.130:9090/targets
可以看到 targets 的狀況(也就是 prometheus config 設定那些目標
可以直接將收集來的資料產生圖片
http://10.110.86.130:3000
顯示介面、告警
可以在官方的圖表庫中 Official & community built dashboards 找別人設定好的圖來用
隨邊找個 postgres 模板
點下 Copy ID to Clipboard
後,回到 Grafana,按下 Create > Import
貼上 Dashboard ID
按下 Load 後,就可以匯入 template 了
或是自己新增
使用 Querying basics | Prometheus 來過濾 Metrics 資料
資料源過濾完後,可以選擇要顯示的圖表樣式
告警服務,這邊需要先設定要連接的平台
然後回到顯示頁面的 Alert 頁
Conditions 觸發的情況下,推到 Notification 那邊
slack