# Query label\_replace function

**URL:** <https://discuss.prometheus.io/t/query-label-replace-function/2262>\
**Category:** PromQL\
**Created:** [May 2, 2024, 1:52pm UTC](https://discuss.prometheus.io/t/query-label-replace-function/2262 "2024-05-02T13:52:37Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![Gowthamoptit](https://dub1.discourse-cdn.com/flex017/user_avatar/discuss.prometheus.io/gowthamoptit/32/963_2.png) [@Gowthamoptit](https://discuss.prometheus.io/u/Gowthamoptit)\
**Post date:** [May 2, 2024, 1:52pm UTC](https://discuss.prometheus.io/t/query-label-replace-function/2262/1 "2024-05-02T13:52:37Z")

</div>

label\_replace(  
(global\_peers\_details),  
“peers\_1”,  
"$1[$1] & $2[$2] ",  
“peers\_1”,  
“(._),(._)”  
)  
I have 3 nodes cluster. so The metric will shows the current node where it connects with other two nodes through label peers\_1.  
when I ran above Prom Query, I get the label **peers\_1** ="BB903[BB903] & BB904[BB904] " as a output which is other two nodes node\_id.  
In the query, I given “$1[$1] & $2[$2]” and “(._),(._)” Because I had only two nodes which replace “,” to “&”.  
Now how can I modify the query like $1[$1} to $32[$32} if I had 32 nodes. Instead of updating manually like "$1[$1] & $2[$2} & $3{$3} & $4[$4] & $5[$5} & $6[$6] etc until $32[$32} and (._),(._),(._),(._) for 32 times . Give a static solution without manual updating for $1, $2 to $32 for each nodes.
