Prometheus 性能调优 - 水平分片

简介: Prometheus 性能调优 - 水平分片

简介

之前笔者有连续 2 篇文章:

陆续介绍了一些 Prometheus 的性能调优技巧,包括高基数问题的解决以及精简 Prometheus 的指标和存储占用。

今天再介绍一个新的调优思路:水平分片。

水平分片

如果你正在面临的不是因为 label 导致的高基数问题,而是因为监控规模的急剧扩张导致需要被监控的 instance 非常庞大时,可以通过 Prometheus 的 hashmod relabel action 来优化性能。通过这种办法,面对成千上万的 instance 时,一台 Prometheus 只需要监控其中的所有各种各样实例的一部分 instance。

📝Notes

Prometheus 也有垂直分片,垂直分片要简单很多,说白了就是配置不同的 job 监控不同的组件即可。

水平分片相对还有些技术含量。

水平分片配置

具体配置如下,使用一台 Prometheus 抓取 targets 的一部分:

global:
  external_labels:
  env: prod
  scraper: 2
scrape_configs:
  - job_name: my_job
    ...
    relabel_configs:
      - source_labels: [__address__]
        modulus: 4
        target_label: __tmp_hash
        action: hashmod
      - source_labels: [__tmp_hash]
        regex: 2
        action: keep
YAML

modulus 里,配置了 4 为基数。每个 Prometheus 只抓取 1/4,比如上面的配置就只抓取 hashmod__temp_hash 为 2 的 targets。

抓取完成后,可以再通过 remote_write Thanos Mimir VM 等方案对这 4 台 Prometheus Server 的数据进行聚合。

🎉🎉🎉

相关文章
|
2月前
|
存储 Prometheus 监控
Prometheus 性能调优 - 什么是高基数问题以及如何解决?
Prometheus 性能调优 - 什么是高基数问题以及如何解决?
|
3月前
|
编解码 Prometheus 运维
Prometheus 的监控方法论
【1月更文挑战第24天】
|
3月前
|
存储 Prometheus 监控
Prometheus vs. ELK Stack:容器监控与日志管理工具的较量
随着容器化技术的广泛应用,容器监控与日志管理成为了关键任务。本文将对两种常用工具进行比较与选择,分别是Prometheus和ELK Stack。Prometheus是一款开源的监控系统,专注于时序数据的收集和告警。而ELK Stack则是一套完整的日志管理解决方案,由Elasticsearch、Logstash和Kibana三个组件组成。通过比较它们的特点、优势和适用场景,读者可以更好地了解如何选择适合自己需求的工具。
|
2月前
|
Prometheus 监控 Kubernetes
如何用 Prometheus Operator 监控 K8s 集群外服务?
如何用 Prometheus Operator 监控 K8s 集群外服务?
|
6月前
|
Prometheus 监控 Cloud Native
【云原生】Docker容器命令监控+Prometheus监控平台
【云原生】Docker容器命令监控+Prometheus监控平台
212 0
【云原生】Docker容器命令监控+Prometheus监控平台
|
2月前
|
Prometheus 监控 Kubernetes
Prometheus Operator 与 kube-prometheus 之二 - 如何监控 1.23+ kubeadm 集群
Prometheus Operator 与 kube-prometheus 之二 - 如何监控 1.23+ kubeadm 集群
|
5月前
|
数据采集 Prometheus 监控
监控利器之Prometheus基于Blackbox_exporter监控服务的端口
监控利器之Prometheus基于Blackbox_exporter监控服务的端口
286 0
|
2月前
|
Prometheus 监控 Cloud Native
使用 Prometheus 配置 SLO 监控和告警
使用 Prometheus 配置 SLO 监控和告警
|
3月前
|
Prometheus 监控 Java
微服务框架(二十四)Prometheus 监控埋点
此系列文章将会描述Java框架Spring Boot、服务治理框架Dubbo、应用容器引擎Docker,及使用Spring Boot集成Dubbo、Mybatis等开源框架,其中穿插着Spring Boot中日志切面等技术的实现,然后通过gitlab-CI以持续集成为Docker镜像。 本文为Prometheus 监控埋点 本系列文章中所使用的框架版本为Spring Boot 2.0.3-REL...
|
3月前
|
Prometheus 监控 Cloud Native
微服务框架(二十二)Prometheus + Grafana 可视化监控
此系列文章将会描述Java框架Spring Boot、服务治理框架Dubbo、应用容器引擎Docker,及使用Spring Boot集成Dubbo、Mybatis等开源框架,其中穿插着Spring Boot中日志切面等技术的实现,然后通过gitlab-CI以持续集成为Docker镜像。 本文为Prometheus + Grafana 可视化监控的介绍,下篇为Prometheus + Grafana...