日本熟妇hd丰满老熟妇,中文字幕一区二区三区在线不卡 ,亚洲成片在线观看,免费女同在线一区二区

開發指南

更新時間:

本文介紹TSDB for Prometheus支持的label運算符和聚合運算。

PromQL參考

PromQL是Prometheus提供的一種功能查詢語言,允許用戶實時選擇和匯總時間序列數據。如要了解更多有關PromQL的內容,請參考Prometheus官方提供的PromQL文檔

TSDB for Prometheus內置實現的remote storage adapter接口,極大程度上兼容Prometheus的查詢功能。

支持的Label運算符

TSDB for Prometheus支持4種label運算符,包括=!==~!~等4種運算符,查詢示例如下:

node__cpu__seconds__total{cpu="1",mode="user"}
node__cpu__seconds__total{cpu!="1",mode="user"}

node__cpu__seconds__total{cpu=~"1",mode="user"}
node__cpu__seconds__total{cpu=~"1|2|3",mode="user"}

node__cpu__seconds__total{cpu!~"1",mode="user"}
node__cpu__seconds__total{cpu!~"1|2|3",mode="user"}

TSDB for Prometheus對于PromQL中的正則表達式匹配,對于=~目前僅支持|*兩個符號。對于!~暫時僅支持|,不支持符號*的查詢。查詢示例如下:

node__cpu__seconds__total{mode=~"user|sys"}    #支持
node__cpu__seconds__total{mode=~"use*"}        #支持
node__cpu__seconds__total{mode=~"user.+"}      #不支持

node__cpu__seconds__total{mode!~"user|sys"}    #支持
node__cpu__seconds__total{mode!~"use*"}        #不支持
node__cpu__seconds__total{mode!~"user.+"}      #不支持

對PromQL的正則表達式查詢的更多支持,TSDB for Prometheus目前正在緊鑼密鼓開發中,敬請期待。

支持的聚合運算

TSDB for Prometheus支持的Prometheus的聚合運算包括:min,max,avg,stddev,stdvar,count,topk,bottomk,quantile,count_values等,查詢示例如下:

min (node__cpu__seconds__total)
max (node__cpu__seconds__total)
avg (node__cpu__seconds__total)
stddev (node__cpu__seconds__total)
stdvar (node__cpu__seconds__total)
count (node__cpu__seconds__total)
topk (1,node__cpu__seconds__total)
bottomk (1,node__cpu__seconds__total)
quantile(1,node__cpu__seconds__total)
count_values("count", node__cpu__seconds__total)

注意事項

Prometheus支持的字符與TSDB支持的字符不同,其具體差異如下表所示:

Prometheus

TSDB

metric

[a-zA-Z:][a-zA-Z0-9:]*

只可包含大小寫英文字母、中文、數字,以及特殊字符 -_./():,[]=‘#

tagKey

[a-zA-Z][a-zA-Z0-9]* ,且以>開頭的tagName保留為內部使用。

只可包含大小寫英文字母、中文、數字,以及特殊字符 -_./():,[]=‘#

tagValue

可以為任意Unicode字符。

只可包含大小寫英文字母、中文、數字,以及特殊字符 -_./():,[]=‘#

注意
  • 由于上述字符支持的差異,數據若通過Prometheus寫入,則建議數據也通過Prometheus查詢。若使用TSDB的原生查詢接口查詢這些數據,獲取的tagvalue有可能出現亂碼。

  • TSDB在對tagValue中不支持的字符進行Encode(編碼)和Decode(解碼)時,使用了#作為標識字符,因此通過Prometheus寫入TSDB的tagValue最好不要包含#字符。

  • 通過Prometheus寫入的數據,如果以TSDB的原生查詢接口讀出,請保證寫入的tagvalue不包含TSDB無法識別的字符。通過TSDB原生寫入接口寫入的數據,如果以Prometheus讀出,請保證寫入的metric,tagkey不包含Prometheus無法識別的字符。