I am very new to both Kubernetes and RabbitMQ, but I am attempting to autoscale pods based on the number of ready messages in my RabbitMQ queue.
I have been following the GCP documentation here and my prometheus rabbitmq container is based on the one found here
From these guides I have created a deployment
apiVersion: apps/v1
kind: Deployment
metadata:
labels:
run: rabbitmq-prometheus-sd
name: rabbitmq-prometheus-sd
namespace: default
spec:
replicas: 1
selector:
matchLabels:
run: rabbitmq-prometheus-sd
template:
metadata:
labels:
run: rabbitmq-prometheus-sd
spec:
containers:
# rabbitmq-exporter container
- name: prometheus
image: kbudde/rabbitmq-exporter:v0.29.0
env:
- name: RABBIT_URL
value: http://MYRABBITMQHOST.rmq.cloudamqp.com:15672
- name: RABBIT_USER
value: MYRABBITMQUSERNAME
- name: RABBIT_PASSWORD
value: MYRABBITMQPASSWORD
- name: PUBLISH_PORT
value: "9419"
# amqp 3.6.9++
- name: RABBIT_CAPABILITIES
value: "bert,no_sort"
# pre-built 'prometheus-to-sd' sidecar container to export prometheus
# metrics to Stackdriver
- name: prometheus-to-sd
image: gcr.io/google-containers/prometheus-to-sd:v0.5.0
command: ["/monitor"]
args:
- --source=:http://localhost:9419
- --stackdriver-prefix=custom.googleapis.com
- --pod-id=$(POD_ID)
- --namespace-id=$(POD_NAMESPACE)
env:
# save Kubernetes metadata as environment variables for use in metrics
- name: POD_ID
valueFrom:
fieldRef:
apiVersion: v1
fieldPath: metadata.uid
- name: POD_NAMESPACE
valueFrom:
fieldRef:
fieldPath: metadata.namespace
I am able to deploy this to my cluster in GKE, however when I check the custom metrics in the metric explorer I can only find these 3 and none others:
Obviously without the queue metrics I cannot create a HPA to scale my application. Any help or guidance on why these metrics are not being delivered or suggested alternate routes would be appreciated.
The issue was that the rabbitmq exporter does not work with rabbitmq hosted on cloudampq. This method to scale was used instead