prometheus抓取保护配置以防止压力过载
场景
担心您的应用程序指标可能突然激增,以及指标突然激增导致prometheus压力过载
就像生活中的许多事情一样,标签要有节制。当带有用户 ID 或电子邮件地址的标签被添加到指标时,虽然它不太可能结束,因为突然之间,您的一个目标可能会在每次抓取时抽出数十万个时间序列,从而导致 Prometheus 出现性能问题。
设置scrap抓取指标过载保护
sample_limit 是一个抓取配置字段,如果返回的时间序列超过给定数量,它将导致抓取失败。默认情况下禁用。例如:文章来源:https://www.toymoban.com/news/detail-489417.html
scrape_configs:
- job_name: 'my_job'
sample_limit: 5000
static_configs:
- targets:
- my_target:1234
如果返回的时间序列超过 5000 个,将导致目标的抓取失败,将 up 设置为 0,就好像目标已关闭一样。从那里,您可以在抓取时使用普罗米修斯删除指标来删除有问题的指标,同时等待应用程序被修复。也就是说metric_relabel_configs在sample_limit之前应用。文章来源地址https://www.toymoban.com/news/detail-489417.html
各类过载保护汇总
- 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 ]
到了这里,关于【博客654】prometheus配置抓取保护以防止压力过载的文章就介绍完了。如果您还想了解更多内容,请在右上角搜索TOY模板网以前的文章或继续浏览下面的相关文章,希望大家以后多多支持TOY模板网!