Queue Count in Prometheus is not getting updated while Using Gauge.builder

I am trying to get the count of a particular queue using Gauge and if the count of the queue is nearing to 100,we have an requirement to Use HPA(Horizontal Pod Autoscaling), But during application start ,If I have ‘rabbit_connection_count’ as 3(lets say), even after submitting 10-20 requests also, the count in Prometheus is not getting increased.

import java.util.Properties; import javax.annotation.PostConstruct; import org.springframework.amqp.rabbit.core.RabbitAdmin; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.boot.context.event.ApplicationReadyEvent; import org.springframework.context.event.EventListener; import org.springframework.stereotype.Service; import com.copart.ids.ws.config.RabbitPrometheusProps; import io.micrometer.core.instrument.Gauge; import io.micrometer.core.instrument.MeterRegistry; import io.micrometer.core.instrument.binder.MeterBinder; import lombok.extern.slf4j.Slf4j;  @Slf4j @Service public class QueueCountPrometheus implements MeterBinder {      @Autowired     private RabbitAdmin rabbitAdmin;      private Gauge gauge;      @Override     public void bindTo(MeterRegistry meterRegistry) {         Integer queueCount = null;         Properties processorProperties = rabbitAdmin                 .getQueueProperties("some_random_queue_name");          if (null != processorProperties) {             queueCount = (Integer) processorProperties.get("QUEUE_MESSAGE_COUNT");             log.info("queue count " + queueCount);          }         Gauge.builder("rabbit_connection_count", null != queueCount ? queueCount : 0, Integer::intValue)                 .description("Number of unserved messages in the queue").register(meterRegistry);      } 

}

Add Comment
0 Answer(s)

Your Answer

By posting your answer, you agree to the privacy policy and terms of service.