Prometheus 配置文件與核心功能

Prometheus 配置文件與核心功能

#全局配置選項(xiàng)

global:

? # 采集被監(jiān)控端的一個(gè)周期 默認(rèn)一分鐘采集一次

? [ scrape_interval: <duration> | default = 1m ]

? # 采集時(shí)的超時(shí)候就 請求接口10s里面沒有響應(yīng)就是失敗的

? [ scrape_timeout: <duration> | default = 10s ]

? # 告警的評(píng)估周期 默認(rèn)是一分鐘

? [ evaluation_interval: <duration> | default = 1m ]

? #web標(biāo)簽

? external_labels:

? ? [ <labelname>: <labelvalue> ... ]


? [ query_log_file: <string> ]

#指定規(guī)則監(jiān)控告警規(guī)則

rule_files:

? [ - <filepath_glob> ... ]

# A list of scrape configurations.

#配置被監(jiān)控指標(biāo)

scrape_configs:

? [ - <scrape_config> ... ]

#配置告警

alerting:

? alert_relabel_configs:

? ? [ - <relabel_config> ... ]

#配置告警組件的連接地址 也可以對告警重新打標(biāo)簽

? alertmanagers:

? ? [ - <alertmanager_config> ... ]

# 寫

remote_write:

? [ - <remote_write> ... ]

# 讀

remote_read:

? [ - <remote_read> ... ]?

relabel_configs

? ? ? static_configs:

? ? - targets: ['localhost:9090']

? ? relabel_configs: #配置規(guī)則

? ? - action: replace #重寫

? ? ? source_labels: ['job'] #標(biāo)簽重新命名

? ? ? regex: (.*) #正則匹配

? ? ? replacement: $1 #使用正則匹配第一個(gè)變量

? ? ? target_label: idc #job修改成IDC



? 統(tǒng)計(jì)機(jī)房cpu使用總和

? ? sum(process_cpu_seconds_total{job="bj"})


relabel_configs 動(dòng)作

action:重新標(biāo)簽動(dòng)作

? replace:默認(rèn),通過regex匹配source_label的值,使用replacement來引用表達(dá)式匹配的分組

? keep:刪除regex與連接不匹配的目標(biāo) source_labels

? drop:刪除regex與連接匹配的目標(biāo) source_labels

? labeldrop:刪除regex匹配的標(biāo)簽

? labelkeep:刪除regex不匹配的標(biāo)簽

? hashmod:設(shè)置target_label為modulus連接的哈希值source_labels

? labelmap:匹配regex所有標(biāo)簽名稱。然后復(fù)制匹配標(biāo)簽的值進(jìn)行分組,replacement分組引用(${1},${2},…)替代?

選擇采集目標(biāo)?(監(jiān)控端)

drop 過濾不需要采集的目標(biāo)

keep 過濾需要采集的目標(biāo)

labeldrop 實(shí)例

? - action: labeldrop

? ? ? regex: job

刪除job

=======================================================

#基于文件的服務(wù)發(fā)現(xiàn)

? azure_sd_configs

? consul_sd_configs

? dns_sd_configs

? ec2_sd_configs

? openstack_sd_configs

? file_sd_configs

? gce_sd_configs

? kubernetes_sd_configs

? marathon_sd_configs

? nerve_sd_configs

? serverset_sd_configs

? triton_sd_configs

=======================================================

文件服務(wù)發(fā)現(xiàn)

? file_sd_configs:

? ? ? - files: ['/usr/local/prometheus/sd_config/*.yml']

? ? ? ? #文件路徑

? ? ? ? refresh_interval: 5s

? ? ? ? #服務(wù)發(fā)現(xiàn)時(shí)間

服務(wù)發(fā)現(xiàn)文件配置

? - targets: ['localhost:9090']

? labels:

? ? idc: CD

總結(jié)

? 當(dāng)你實(shí)例很多時(shí) 有很多動(dòng)態(tài)縮容擴(kuò)容這樣非常適合 動(dòng)態(tài)發(fā)現(xiàn)的

? Prometheus會(huì)定期去掃文件看有沒有修改 有修改就添加新的實(shí)例進(jìn)來

?著作權(quán)歸作者所有,轉(zhuǎn)載或內(nèi)容合作請聯(lián)系作者
【社區(qū)內(nèi)容提示】社區(qū)部分內(nèi)容疑似由AI輔助生成,瀏覽時(shí)請結(jié)合常識(shí)與多方信息審慎甄別。
平臺(tái)聲明:文章內(nèi)容(如有圖片或視頻亦包括在內(nèi))由作者上傳并發(fā)布,文章內(nèi)容僅代表作者本人觀點(diǎn),簡書系信息發(fā)布平臺(tái),僅提供信息存儲(chǔ)服務(wù)。

相關(guān)閱讀更多精彩內(nèi)容

友情鏈接更多精彩內(nèi)容