<p>I use Horizontal Pod Autoscaler with <code>External</code> metric based on a value provided by DataDog agent</p>
<pre class="lang-yaml prettyprint-override"><code>apiVersion: datadoghq.com/v1alpha1
kind: DatadogMetric
metadata:
  name: queue-size
spec:
  query: &quot;max:redis.key.length{key:my-tasks}.fill(zero)&quot;
</code></pre>
<p>Corresponding HPA configuration</p>
<pre class="lang-yaml prettyprint-override"><code>apiVersion: autoscaling/v2beta2
kind: HorizontalPodAutoscaler
spec:
  scaleTargetRef:
    apiVersion: apps/v1
    kind: Deployment
    name: celery-worker
  metrics:
  - type: External
    external:
      metric:
        name: &quot;datadogmetric@default:queue-size&quot;
</code></pre>
<p>I want workers to be scaled almost immediately as queue grows, so need polling period to be at most <code>2-5</code> seconds. By default it's 30 seconds (<a href="https://docs.datadoghq.com/agent/cluster_agent/external_metrics/?tab=helm#example-hpa" rel="nofollow noreferrer">as per docs</a>)</p>
<p><a href="https://i.stack.imgur.com/9SyRN.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/9SyRN.png" alt="enter image description here" /></a></p>
<p>How do I change poll interval on k8s side? Is there a flag when configuring HPA or should I tune DataDog agent instead?</p>

Most Wanted
<p>Kubernetes implements horizontal pod autoscaling as a control loop that runs intermittently (it is not a continuous process). The interval is set by the <em><strong>--horizontal-pod-autoscaler-sync-period</strong></em> parameter to the <strong>kube-controller-manager</strong> (and the default interval is 15 seconds). You should tweak the value as per your requirement</p>
