1、默認配置
shell> cat /Download/prometheus/prometheus.yml | grep -v "#"
global:
alerting:
alertmanagers:
- static_configs:
- targets:
rule_files:
scrape_configs:
- job_name: 'docker38'
scrape_interval: 5s
static_configs:
- targets: ['localhost:9090']
labels:
instance: docker38
2、模塊介紹
示例配置文件中有三個配置塊:global,rule_files和scrape_configs。
global
全局塊控制Prometheus服務器的全局配置。 我們有兩種選擇。 第一個是scrape_interval,它控制Prometheus抓取目標的頻率。 您可以爲單個目標重寫此值。 在這種例子下,全局設置是每15s抓取一次。 evaluation_interval選項控制Prometheus評估規則的頻率。 Prometheus使用規則創建新的時間序列並生成警報。
rule_files
rule_files塊指定我們希望Prometheus服務器加載的任何規則的位置。 現在我們沒有規則
scrape_configs
最後一個塊scrape_configs控制Prometheus監視的資源。 由於Prometheus還將自己的數據公開爲HTTP端點,因此它可以抓取並監控自身的健康狀況。 在默認配置中,有一個名爲prometheus的作業,它會抓取Prometheus服務器公開的時間序列數據。 該作業包含一個靜態配置的目標,即端口9090上的localhost。Prometheus希望指標在/metrics路徑上的目標上可用。 所以這個默認的工作是通過URL抓取:http//localhost:9090/metrics。