企業(yè)網(wǎng)站優(yōu)化找哪家搜索排行
prometheus抓取保護配置以防止壓力過載
場景
擔(dān)心您的應(yīng)用程序指標(biāo)可能突然激增,以及指標(biāo)突然激增導(dǎo)致prometheus壓力過載
就像生活中的許多事情一樣,標(biāo)簽要有節(jié)制。當(dāng)帶有用戶 ID 或電子郵件地址的標(biāo)簽被添加到指標(biāo)時,雖然它不太可能結(jié)束,因為突然之間,您的一個目標(biāo)可能會在每次抓取時抽出數(shù)十萬個時間序列,從而導(dǎo)致 Prometheus 出現(xiàn)性能問題。
設(shè)置scrap抓取指標(biāo)過載保護
sample_limit 是一個抓取配置字段,如果返回的時間序列超過給定數(shù)量,它將導(dǎo)致抓取失敗。默認(rèn)情況下禁用。例如:
scrape_configs:- job_name: 'my_job'sample_limit: 5000static_configs:- targets:- my_target:1234
如果返回的時間序列超過 5000 個,將導(dǎo)致目標(biāo)的抓取失敗,將 up 設(shè)置為 0,就好像目標(biāo)已關(guān)閉一樣。從那里,您可以在抓取時使用普羅米修斯刪除指標(biāo)來刪除有問題的指標(biāo),同時等待應(yīng)用程序被修復(fù)。也就是說metric_relabel_configs在sample_limit之前應(yīng)用。
各類過載保護匯總
- sample_limit
# Per-scrape limit on number of scraped samples that will be accepted.
# If more than this number of samples are present after metric relabeling
# the entire scrape will be treated as failed. 0 means no limit.
[ sample_limit: <int> | default = 0 ]
- body_size_limit:
# An uncompressed response body larger than this many bytes will cause the
# scrape to fail. 0 means no limit. Example: 100MB.
# This is an experimental feature, this behaviour could
# change or be removed in the future.
[ body_size_limit: <size> | default = 0 ]
- label_limit
# Per-scrape limit on number of labels that will be accepted for a sample. If
# more than this number of labels are present post metric-relabeling, the
# entire scrape will be treated as failed. 0 means no limit.
[ label_limit: <int> | default = 0 ]
- label_name_length_limit
# Per-scrape limit on length of labels name that will be accepted for a sample.
# If a label name is longer than this number post metric-relabeling, the entire
# scrape will be treated as failed. 0 means no limit.
[ label_name_length_limit: <int> | default = 0 ]
- label_value_length_limit
# Per-scrape limit on length of labels value that will be accepted for a sample.
# If a label value is longer than this number post metric-relabeling, the
# entire scrape will be treated as failed. 0 means no limit.
[ label_value_length_limit: <int> | default = 0 ]
- target_limit
# Per-scrape config limit on number of unique targets that will be
# accepted. If more than this number of targets are present after target
# relabeling, Prometheus will mark the targets as failed without scraping them.
# 0 means no limit. This is an experimental feature, this behaviour could
# change in the future.
[ target_limit: <int> | default = 0 ]