普罗米修斯指标连接无法按我的预期工作
我有两个Prometheus指标,kube_pod_info和kube_pod_container_status_restarts_total。而且我需要将我的电报警报纳入两个数据。
kube_pod_container_status_restarts_total {project =“ abc”,env =“ prod”,namespace!=“ test”}返回{container:servication-bridge-v0,devoryconfig:servication-bridge-v0-3 ,工作:Kube-State-Metrics,Mgroup:业务,名称空间:Stowf-prod,Origin_prometheus:Prometheus,Pod:Service-Bridge-V0-8-FL4BQ,项目:ABC,服务:Kube-State-Metrics}
和Kube_pod_info { project =“ abc”,env =“ prod”,namespace!=“ test”} return {容器:kube-abcd-proxy-main,created_by_kind:,, creats_by_name:,created_by_name:,endpoint:https-main,env:https-main,env:prod ford ford:prod,host,host_ip:10.46 .71.101, job: kube-state-metrics, mgroup: business, namespace: stowf-prod, node: sof-oc4m0w01.mycompany.org, origin_prometheus: Prometheus, pod: advertising-v1-4-deploy, pod_ip: 10.241.17.170 ,项目:ABC,服务:Kube-State-Metrics,UID:14E88AAE-B3FB-4DD5-A77F-565725046489}
,但我需要这样的输出:{DevolyConfig:servication-Bridge-v0-8,env: service-bridge-v0-8-fl4BQ,节点:sof-oc4m0w02.mycompany.org,pod:service-bridge-v0-8-fl4BQ,project:abc}
我尝试过“* on(pod)”或“* on* on* on* on* (这两个指标中的任何一个同一标签)”,但仅在 * on(pod)的左侧获得“重复的时间序列”。 !=“ test”} * on(pod)kube_pod_container_status_restarts_total {project =“ abc”,env =“ prod”,namesspace!=“ test”}无法执行QUERY:无法评估“ Kube_pod_info {kube_pod_info {abc”,env =“ abc”,eNT =“ abc”,eNT =“”, prod”,namespace!=“ test”} * on(pod)kube_pod_container_status_restarts_total {project =“ abc”,env =“ prod”,namespace!=“ test”}: )
然后我尝试“忽略”标签,但获得了“不再显示datat来显示”示例查询:kube_pod_info {project =“ abc”,env =“ prod”,namespace!=“ test”} / nignoring(devolyconfig,decloveryconfig,created_by_by_kind,create_by_by_name,create_by_name ,host_ip,pod_ip,uid,node)kube_pod_container_status_restarts_total {project =“ abc”,env =“ prod”,namespace!=“ test”}
将“许多”分组为“许多”,但是当我需要削减不必要的标签,但是我需要切断不必要的标签,获取消息我不需要它们。示例查询:kube_pod_info * on(uid)group_left(instance)(速率(kube_pod_container_status_restarts_total {project =“ abc”,env =“ ford”,namespace”,namespace!=“ test”} [10m] * 600) * 600) -abcd-proxy-main, created_by_kind: ReplicationController, created_by_name: service-bridge-v0-8, deployconfig: service-bridge-v0-8, endpoint: https-main, env: prod, host_ip: 10.46.71.101, instance: service -bridge-v0-8-fl4bq, job: kube-state-metrics, mgroup: business, namespace: stowf-prod, node: sof-oc4m0w02.mycompany.org, origin_prometheus: Prometheus, pod: service-bridge-v0-8 -fl4BQ,POD_IP:10.241.17.170,项目:ABC,服务:Kube-State-Metrics,UID:0680C9D55-5364-4509-90D5-C855-C8D7F21AC352
}最后一个查询。谢谢你!
I have two prometheus metrics, kube_pod_info and kube_pod_container_status_restarts_total. And i need to enreach my telegram alert with data from both of them.
kube_pod_container_status_restarts_total{project="abc",env = "prod",namespace!="test"} returns {container: service-bridge-v0, deployconfig: service-bridge-v0-3, endpoint: https-main, env: prod, job: kube-state-metrics, mgroup: business, namespace: stowf-prod, origin_prometheus: Prometheus, pod: service-bridge-v0-8-fl4bq, project: abc, service: kube-state-metrics}
And kube_pod_info{project="abc",env="prod",namespace!="test"} returns {container: kube-abcd-proxy-main, created_by_kind: , created_by_name: , endpoint: https-main, env: prod, host_ip: 10.46.71.101, job: kube-state-metrics, mgroup: business, namespace: stowf-prod, node: sof-oc4m0w01.mycompany.org, origin_prometheus: Prometheus, pod: advertising-v1-4-deploy, pod_ip: 10.241.17.170, project: abc, service: kube-state-metrics, uid: 14e88aae-b3fb-4dd5-a77f-565725046489}
But, i need output like this: {deployconfig: service-bridge-v0-8, env: prod, instance: service-bridge-v0-8-fl4bq, node: sof-oc4m0w02.mycompany.org, pod: service-bridge-v0-8-fl4bq, project: abc}
I have tried "* on(pod)" or "* on (any of the same label in the both metrics)", but getting only "duplicate time series on the left side of * on (pod)" error Example query: kube_pod_info { project = "abc", env = "prod", namespace != "test" } * on(pod) kube_pod_container_status_restarts_total { project = "abc", env = "prod", namespace != "test" } cannot execute query: cannot evaluate "kube_pod_info{project="abc", env="prod", namespace!="test"} * on (pod) kube_pod_container_status_restarts_total{project="abc", env="prod", namespace!="test"}": duplicate time series on the left side of * on (pod)
Then i tried "ignoring" labels, but got "no more datat to show" Example query: kube_pod_info { project = "abc", env = "prod", namespace != "test" } / ignoring(deployconfig,created_by_kind,created_by_name,host_ip,pod_ip,uid,node) kube_pod_container_status_restarts_total { project = "abc", env = "prod", namespace != "test" }
Grouping "many to many" works fine, but i need to cut off unnecessary labels, when i get message i don't need them. Example query: kube_pod_info * on(uid) group_left(instance) (rate ( kube_pod_container_status_restarts_total { project = "abc", env = "prod", namespace != "test" } [10m] ) * 600) Answer: {container: kube-abcd-proxy-main, created_by_kind: ReplicationController, created_by_name: service-bridge-v0-8, deployconfig: service-bridge-v0-8, endpoint: https-main, env: prod, host_ip: 10.46.71.101, instance: service-bridge-v0-8-fl4bq, job: kube-state-metrics, mgroup: business, namespace: stowf-prod, node: sof-oc4m0w02.mycompany.org, origin_prometheus: Prometheus, pod: service-bridge-v0-8-fl4bq, pod_ip: 10.241.17.170, project: abc, service: kube-state-metrics, uid: 0680c9d5-5364-4509-90d5-c8d7f21ac352}
So, i need help to "ignore" unusble labels, or cut off them from the last query. Thank you!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
运算符基本上基于提供的标签列表,运算符基本上匹配左右对。但是,如果从列表中有超过1个系列具有相同的标签值对,那么您会收到有关重复项的错误。
考虑以下示例:
如果运行以下查询:
您将获得有关重复的错误在以下内容中:
要使它起作用,您需要在上指定其他标签::
on(namespace,pod,service)
,这将导致以下时间序列集:请注意,仅选择标签
服务
。您很可能有不同的标签或多个标签,使输出与众不同。The
on
operator basically matches left and right pairs based on the list of provided labels. But if there are more than 1 series with identical label-value pairs from the list - you get an error about duplicates.Consider the example:
If you run the following query:
you'll get an error about duplicates because
namespace
andpod
pairs will match two different time series on both sides transforming the data into the following:To make it work, you need to specify additional label in
on
:on(namespace, pod, service)
which would result in the following time series set:Please note, label
service
was picked only for example. It is very likely you have a different label or multiple labels which make the output unique.