prometheus icon indicating copy to clipboard operation
prometheus copied to clipboard

label_replace()函数理解

Open 1046102779 opened this issue 8 years ago • 5 comments

label_replace函数,输入:瞬时向量,输出:key: value = 度量指标: 值(要替换的内容:首先 ,针对src_label标签,对该标签值进行regex正则表达式匹配。如果不能匹配的度量指标,则不发生任何改变;否则,如果匹配,则把dst_label标签的标签纸替换为replacement 例子:度量指标样本数据:http_requests_total{code="400",handler="query",instance="120.77.65.193:9090",job="prometheus",method="get"} 9 label_replace函数执行 label_replace(http_requests_total{code="400",handler="query",instance="120.77.65.193:9090",job="prometheus",method="get"}, "instance", "hello,world", "method", "ge.*") 显示结果: http_requests_total{code="400",handler="query",instance="hello,world",job="prometheus",method="get"} 9

1046102779 avatar Apr 22 '17 08:04 1046102779

如果我想要把instance="120.77.65.193:9090" 去掉“:9090”取值 "120.77.65.193",是否有方法?

wkjun avatar Oct 31 '17 08:10 wkjun

这个不懂了,很久没搞监控了。不好意思,才回

在 2017-10-31 16:45:30,"wkjun" [email protected] 写道:

如果我想要把instance="120.77.65.193:9090" 去掉“:9090”取值 "120.77.65.193",是否有方法?

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub, or mute the thread.

1046102779 avatar Nov 01 '17 00:11 1046102779

如果我想要把instance="120.77.65.193:9090" 去掉“:9090”取值 "120.77.65.193",是否有方法?

label_replace(expression ,"instance","$1","instance","(.):.")

fengyuceNv avatar Nov 09 '18 06:11 fengyuceNv

如果我想要把instance="120.77.65.193:9090" 去掉“:9090”取值 "120.77.65.193",是否有方法?

label_replace(exp, "instance","$1","instance","(.星号):(.星号)")

pengzuhao avatar Nov 20 '20 07:11 pengzuhao

如果我想要把instance="120.77.65.193:9090" 去掉“:9090”取值 "120.77.65.193",是否有方法?

label_replace(exp, "instance","$1","instance","(.星号):(.星号)")

虽然早就忘记了这个提问,不过还是很感谢你的回复,最近在学Django,有机会可能得向你请教

wkjun avatar Nov 20 '20 16:11 wkjun