apiVersion: autoscaling/v2beta2
kind: HorizontalPodAutoscaler
metadata:
  name: consumer-scaler
  namespace: app
  annotations:
    metric-config.external.prometheus-query.prometheus/prometheus-server: http://prometheus.monitoring.svc
    metric-config.external.prometheus-query.prometheus/messages-count: |
      rabbbitmq_queue_messages_count{queue="queue-name"}
spec:
  scaleTargetRef:
    apiVersion: apps/v1
    kind: StatefulSet
    name: consumer
  minReplicas: 1
  maxReplicas: 50
  metrics:
  - type: External
    external:
      metric:
        name: prometheus-query
        selector:
          matchLabels:
            query-name: messages-count
      target:
        type: Value
        value: 30
