我想检查某个指标是否在普罗米修斯中不可用 5 分钟。
我正在使用absent(K_KA_GCPP)并给出 5 分钟阈值。但似乎我无法将缺少的功能分组到某些标签(例如站点 ID)上。
如果指标不适用于所有 4 个站点 ID,则缺席有效。我想查明所有 4 个站点 ID 中的 1 个站点 ID 的指标是否不可用或不存在,并且我不想在查询中对站点 ID 标签进行硬编码,它应该是通用的。我有什么办法可以做到这一点吗?
我下载的prometheus版本是2.3.2
wget https://github.com/prometheus/prometheus/releases/download/v2.3.2/prometheus-2.3.2.linux-amd64.tar.gz
Run Code Online (Sandbox Code Playgroud)
untared 和 prometheus 已经作为服务运行。
我想使用 promtool 验证我的 Prometheus 警报管理器规则。从下面的博客创建了一个规则。
https://petargitnik.github.io/blog/2018/01/04/how-to-write-rules-for-prometheus
当我运行 promtool 检查规则 /etc/prometheus/prometheus.rules.yml
它说,没有安装 Promtheus,所以使用 apt get prometheus 再次安装
但这是安装了旧版的 promtool,这里是版本详细信息:
root@UTVA-kafka-msg-size-2mb-02509:/home/ubuntu# promtool version
prometheus, version 0.16.2+ds (branch: debian/sid, revision: 0.16.2+ds-1ubuntu1)
build user: pkg-go-maintainers@lists.alioth.debian.org
build date: 20160408-04:15:29
go version: go1.6
Run Code Online (Sandbox Code Playgroud)
Prometheus 版本 2 使用 yml 文件作为规则,较旧的使用一些不同的文件,所以我的 promtool 检查规则失败了。
谁能建议如何升级最新的promtool?
谢谢。
假设我有一个request_failures用户指标。对于每个用户,我向指标添加一个唯一的标签值。因此,对于用户u1,当请求失败两次时,我得到以下指标:
request_failures{user_name="u1"} 2
Run Code Online (Sandbox Code Playgroud)
我还有一条规则,当出现新的失败时就会触发。其表达式为:
increase(request_failures[1m]) > 0
Run Code Online (Sandbox Code Playgroud)
这对于已经遇到故障的用户来说非常有效。例如,当 u1 遇到第三次失败时,规则就会触发。
当新用户u2的请求失败时,我得到的指标如下:
request_failures{user_name="u1"} 2
request_failures{user_name="u2"} 1
Run Code Online (Sandbox Code Playgroud)
现在的问题是警报规则不会针对u2触发。该规则似乎无法识别“新指标”,尽管所有三个指标都是相同的request_failures,只是具有不同的标签。
任何人都可以指出我应该如何构建规则?
我们在 Win Server 上运行 prometheus,在单独的服务器(客户端)上运行 WMI 导出器。能够读取 Prometheus 中的客户端指标。现在的要求是当 Diskspace =>90 % 时,发送电子邮件警报,以便我们可以使用自动作业/手动作业运行作业来清理空间。
您能帮忙了解如何配置磁盘空间 >90 的警报吗
我有一个查询,我试图在一个标签上连接两个指标。K_Status_Value == 5 和 ON(macAddr) state_details{live="True"}
标签 macAddr 出现在两个指标中。标签的值有时以大写 (78:32:5A:29:2F:0D) 有时以小写 (78:72:5d:39:2f:0a) 出现在“K_Status_Value”中,但始终以大写出现'state_details' 的情况。有什么方法可以使查询中的标签 macAddr 值不区分大小写,以便我不会错过案例不匹配的情况?
我正在尝试在 Prometheus 的alert.rules 文件中设置一个警报,该警报仅在特定时间段内触发。我已经在 expr 标签内测试了下面的代码块,没有时间限制,并且它工作得非常好。
正如PromQL 文档:hour()所述,hour()根据当前 UTC 返回 0 到 23 之间的值。
- alert: test_down
expr: absent(container_memory_usage_bytes{name="test_ap"}) and hour() > 5 and hour() < 22
for: 30s
labels:
severity: critical
annotations:
summary: "test_ap down"
description: "test_ap is down for more than 30 seconds."
Run Code Online (Sandbox Code Playgroud)
但在这里,不会触发任何警报通知。有谁知道为什么没有任何东西被解雇以及我该如何解决这个问题?
编辑:我已经解决了。我不明白为什么我必须像我这样做的方式那样做,但以下方法有效:
替换and hour() > 5 and hour() < 22为and ON() hour() > 5 < 22
我正在开发一个仪表板,它接收所有 Alertmanager 读数并处理它们。我在请求负载中寻找一个唯一的字段,以在我的数据库中创建一个唯一的外部警报 ID。请求负载看起来像这样:
{
"status": "firing",
"labels": {
"alertname": "",
"app": "",
"cluster": "",
"deployed_location": "",
"instance": "",
"job": "",
"kubernetes_namespace": "",
"kubernetes_pod_name": "",
"pod_template_hash": "",
"release": "",
"replica": "",
"severity": ""
},
"annotations": {
"description": "",
"summary": ""
},
"startsAt": "",
"endsAt": "",
"generatorURL": "",
"fingerprint": ""
}
Run Code Online (Sandbox Code Playgroud)
我第一次使用该generatorURL字段,但后来意识到许多不同的警报具有相同的值generatorURL。我一直在努力fingerprint,情况好多了。但是,我遇到过 2 到 15 个警报具有相同fingerprint.
我想知道:
fingerprint,则不要在我的数据库中创建事件fingerprint已使用。我还担心,如果我设置unique=True警报模型,一些具有相同指纹的新警报将会被错过......我正在尝试将自定义警报路由配置添加到我的警报管理器中,作为 kube-prometheus-stack 的一部分部署。但是 prometheus-operator pod 在尝试生成alertmanager configmap 时,由于以下错误而失败:
level=error ts=2021-05-31T06:29:38.883470881Z caller=klog.go:96 component=k8s_client_runtime func=ErrorDepth msg="Sync \"infra-services/prometheus-operator-kube-p-alertmanager\" failed: provision alertmanager configuration: base config from Secret could not be parsed: yaml: unmarshal errors:\n line 19: field matchers not found in type config.plain"
Run Code Online (Sandbox Code Playgroud)
我还在alertmanager容器内使用amtool验证了相同的内容,这给出了相同的错误。这是我的alertmanager.yml 文件:
global:
resolve_timeout: 5m
slack_api_url: https://hooks.slack.com/services/xxxxxx/yyyyy/zzzzzzzzzzz
receivers:
- name: slack-notifications
slack_configs:
- channel: '#alerts'
send_resolved: true
text: '{{ template "slack.myorg.text" . }}'
- name: blackhole-receiver
route:
group_by:
- alertname
group_interval: 5m
group_wait: 30s
receiver: blackhole-receiver
repeat_interval: 12h
routes:
- matchers: …Run Code Online (Sandbox Code Playgroud) 我是 prometheus 的新手,所以做了一些研究,发现它对于监控应用程序很有帮助,有很多增加计数器来检查 api 调用的例子。我的用例有些不同,我有一个 Rest API,它连接到数据库执行查询并以 JSON 格式返回数据。例如:
{
"dskreads": 26815,
"bufreads": 14451041,
"dskwrites": 52471,
"bufwrites": 569468,
"isamtot": 18439806,
"isopens": 432586,
"isstarts": 408604,
"isreads": 6962799,
"iswrites": 80438,
"isrewrites": 54535,
"isdeletes": 54469,
"iscommits": 61673,
"isrollbacks": 0,
"latchwts": 190,
"buffwts": 192,
"lockreqs": 13921801,
"lockwts": 0,
"ckptwts": 7,
"deadlks": 0,
"lktouts": 0,
"numckpts": 106,
"plgpagewrites": 11106,
"plgwrites": 460,
"llgrecs": 552829,
"llgpagewrites": 49076,
"llgwrites": 43672,
"pagreads": 76446,
"pagwrites": 68495,
"flushes": 107,
"compress": 15039,
"fgwrites": 0,
"lruwrites": 0,
"chunkwrites": 8195,
"btraidx": 1627,
"dpra": 3933, …Run Code Online (Sandbox Code Playgroud) Prometheus-operator 似乎生成promethues-operated仅指向端口 9090 的 Prometheus 实例的服务。
这项服务有什么作用?我们定义其他服务来指向我们的 Prometheus 集群。
取消服务会产生什么影响prometheus-operated?
kubernetes prometheus prometheus-operator kubernetes-service prometheus-alertmanager