|NO.Z.00316|——————————|CloudNative|——|KuberNetes&运维.V36|——|监控.v13|PromQL处理_Label|

一、对label进行处理
### --- 2个label合并,赋值成一个新的label

~~~     # 函数:label_join
~~~     表达式:label_join(node_filesystem_files_free, "new_label","","instance","mountpoint"):把instance和mountpoint这2label的值赋值给new-label的值
~~~     输出结果:new_label="k8s-master01/boot:可以根据自己定义的规则,生成一个新的label
二、label_replace:赋值成一个新的label
### --- 对label的value进行正则匹配,赋值给新的label

~~~     函数:label_replace
~~~     表达式:取值$1:label_replace(node_filesystem_files_free, "host","$1","instance","(.*)-(.*)")
~~~     输出结果:host="k8s 
### --- 函数:label_replace

~~~     表达式:取值$2:label_replace(node_filesystem_files_free, "host","$2","instance","(.*)-(.*)")
~~~     输出结果:host="master01"    host="node01"    host="node02"

 
 
 
 
 
 
 
 
 

Walter Savage Landor:strove with none,for none was worth my strife.Nature I loved and, next to Nature, Art:I warm'd both hands before the fire of life.It sinks, and I am ready to depart
                                                                                                                                                   ——W.S.Landor

 

 

posted on   yanqi_vip  阅读(108)  评论(0编辑  收藏  举报

相关博文:
阅读排行:
· 全程不用写代码,我用AI程序员写了一个飞机大战
· MongoDB 8.0这个新功能碉堡了,比商业数据库还牛
· 记一次.NET内存居高不下排查解决与启示
· DeepSeek 开源周回顾「GitHub 热点速览」
· 白话解读 Dapr 1.15:你的「微服务管家」又秀新绝活了
< 2025年3月 >
23 24 25 26 27 28 1
2 3 4 5 6 7 8
9 10 11 12 13 14 15
16 17 18 19 20 21 22
23 24 25 26 27 28 29
30 31 1 2 3 4 5

导航

统计

点击右上角即可分享
微信分享提示