Yes Brain, I tried using label_replace but every time i get error below is 
my query which i tried.

avg by(name, 
container_label_com_docker_swarm_node_id)(rate(label_replace(container_cpu_usage_seconds_total{container_label_com_docker_swarm_task_name=~".+",
 
name=~".+"}, "name", "$1", "name", "(.*)"[30s]))) * 100

Normal Query with label_replace with output is below:
avg by(name, container_label_com_docker_swarm_node_id) 
(rate(container_cpu_usage_seconds_total{container_label_com_docker_swarm_task_name=~".+"}[30s]))
 
* 100


{container_label_com_docker_swarm_node_id="z2cjapl00v69kmfjpmsin79lc",name="telegraf.1.l0gqe5th54e1ko8f2kdynl5q9"}
  
   0.12159615838850078
{container_label_com_docker_swarm_node_id="z2cjapl00v69kmfjpmsin79lc",name="prometheus.1.14sp9pvx6y8mb5ymq7ev60fns"}
  
 0.2783589968152833
{container_label_com_docker_swarm_node_id="z2cjapl00v69kmfjpmsin79lc",name="cadvisor.z2cjapl00v69kmfjpmsin79lc.hwiz9dknbul892jo0jcq4h829"}
 
1.215465595861067  


Output i am looking for is:(there are 2 dots in the name and i am looking 
the value before the second dot as below)


{container_label_com_docker_swarm_node_id="z2cjapl00v69kmfjpmsin79lc",name="telegraf.1"}
  
                                                              
0.12159615838850078
{container_label_com_docker_swarm_node_id="z2cjapl00v69kmfjpmsin79lc",name="prometheus.1"}
  
                                                      0.2783589968152833
{container_label_com_docker_swarm_node_id="z2cjapl00v69kmfjpmsin79lc",name="cadvisor.z2cjapl00v69kmfjpmsin79lc"}
  
             1.215465595861067  

On Thursday, 20 August 2020 at 17:50:32 UTC+5:30 b.ca...@pobox.com wrote:

> Show some output from the query (including full label sets) and how you've 
> tried using label_replace.
>

-- 
You received this message because you are subscribed to the Google Groups 
"Prometheus Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to prometheus-users+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/prometheus-users/4d5af776-278d-4412-a21c-433970a70434n%40googlegroups.com.

Reply via email to