我使用Prometheus来衡量业务指标,如:
# HELP items_waiting_total Total number of items in a queue
# TYPE items_waiting_total gauge
items_waiting_total 149
Run Code Online (Sandbox Code Playgroud)
我想保留这些数据非常长期(保留5年),我不需要scrape_interval中的高频率.所以我成立了scrape_interval: "900s".
当我用60s分辨率检查普罗米修斯的图形时,它显示了拍打,但事实并非如此.
问题是,普罗米修斯的最大(推荐)scrape_interval是多少?
我在 AWS 上设置了 kubernetes 集群,我尝试使用 cAdvisor + Prometheus + Alert manager 来监控多个 pod。如果容器 / pod 出现故障或卡在 Error 或 CarshLoopBackOff 状态或除了运行之外的任何其他状态,我想要做的是启动电子邮件警报(带有服务/容器名称)。
在普罗米修斯配置中,我有以下规格的工作:
- job_name: name_of_my_job
scrape_interval: 5m
scrape_timeout: 30s
metrics_path: /metrics
scheme: http
Run Code Online (Sandbox Code Playgroud)
创建指标的脚本需要 3 分钟才能完成,但从普罗米修斯我看不到指标。scrape_timeout变量的作用是什么?
我有两个不同(但相关的指标)。
metric_1(id="abc",id2="def")
metric_2(id="abc",id2="def")
Run Code Online (Sandbox Code Playgroud)
我的最终目标是在 Grafana 中实现以下目标。我计划使用“即时”值和 Grafana 的表可视化小部件来显示这些数据。
id id2 metric1 metric2
abc def 1 2
Run Code Online (Sandbox Code Playgroud)
我应该使用什么查询/加入/重新标记来实现这一点?
先感谢您!:)
我在Centos上配置了prometheus,版本详情如下。
prometheus-2.5.0.linux-386
Run Code Online (Sandbox Code Playgroud)
我在 prometheus.yml 配置文件中添加了两个目标,所有服务器节点导出器都在运行。配置如下,
scrape_configs:
- job_name: "node"
scrape_interval: "15s"
target_groups:
- targets: ['192.168.x.x:9100','192.168.x.y:9100']
Run Code Online (Sandbox Code Playgroud)
但是在 prometheus UI Tragets 中只显示单个节点其他没有显示。如果我删除一个节点,则显示现有节点。如何监控多个节点。但是在 Grafana 仪表板中显示Multiple Series Error。
我需要在我的应用程序中查询收集的指标,我发现这样做的唯一方法是通过 Prometheus rest api,如下所述:https : //prometheus.io/docs/prometheus/latest/querying/api/是否有任何 Spring 或是否存在用于从 Prometheus 获取指标的 java api,这样我就不必从头开始实现它?
根据 Prometheus 文档,为了使用直方图指标获得第 95 个百分点,我可以使用以下查询:
histogram_quantile(0.95, sum(rate(http_request_duration_seconds_bucket[5m])) by (le))
Run Code Online (Sandbox Code Playgroud)
资料来源:https : //prometheus.io/docs/practices/histograms/#quantiles
由于直方图的每个桶都是一个计数器,我们可以计算每个桶的比率为:
范围向量中时间序列的每秒平均增长率。
请参阅:https : //prometheus.io/docs/prometheus/latest/querying/functions/#rate
因此,例如,如果桶值[t-5m] = 100 和桶值[t] = 200,则桶率[t] = (200-100)/(10*60) = 0.167
最后,最令人困惑的部分是 histogram_quantile 函数如何在知道所有桶率的情况下找到给定指标的第 95 个百分位数?
是否有任何代码或算法可以让我更好地理解它?
我知道 CPU 利用率是由非空闲时间占 CPU 总时间的百分比给出的。在普罗米修斯,rate或irate函数计算向量数组的变化率。
人们通常通过以下 PromQL 表达式来计算 CPU 利用率:
(100 - (avg by (instance) (rate(node_cpu_seconds_total{mode="idle"}[1m])) * 100))
Run Code Online (Sandbox Code Playgroud)
我不明白计算非空闲时间的每秒变化如何等同于计算 CPU 使用率。有人可以从数学上解释为什么这是有道理的吗?
我在 Kubernetes 中运行 Prometheus 并遇到一些 kube 状态指标连接错误。试图检查日志,但无法在日志中看到连接失败。无论如何,是否可以启用 Prometheus 的详细日志记录?
应用程序在版本 2.2.6 下正常工作,但随着应用程序升级到最新版本的 spring boot 2.3.0,它停止工作并在启动过程中失败。
2020-05-20T08:43:04.408+01:00 [APP/PROC/WEB/0] [OUT] 2020-05-20 07:43:04.407 ERROR 15 --- [ main] o.s.b.web.embedded.tomcat.TomcatStarter : Error starting Tomcat context. Exception: org.springframework.beans.factory.UnsatisfiedDependencyException. Message: Error creating bean with name 'webMvcMetricsFilter' defined in class path resource [org/springframework/boot/actuate/autoconfigure/metrics/web/servlet/WebMvcMetricsAutoConfiguration.class]: Unsatisfied dependency expressed through method 'webMvcMetricsFilter' parameter 0; nested exception is org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'compositeMeterRegistry' defined in class path resource [org/springframework/boot/actuate/autoconfigure/metrics/CompositeMeterRegistryConfiguration.class]: Unsatisfied dependency expressed through method 'compositeMeterRegistry' parameter 1; nested exception is org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'prometheusMeterRegistry' defined …
prometheus ×10
devops ×1
docker ×1
histogram ×1
kubernetes ×1
percentile ×1
promql ×1
rate ×1
spring ×1