<p>I have following yaml-configuration for my horizontal pod autoscaler in GCP.</p>
<pre><code>//...
  metrics:
    - type: Pods
      pods:
        metric:
          name: &quot;my-custom-metric&quot;
        target:
          type: AverageValue
          averageValue: 60

//..
</code></pre>
<p>I have added the metric as a custom metric in metric explorer in Cloud Monitoring. It is a log based metric. I have even added it to a dashboard and it looks fine.</p>
<p>For HPA the metric is not found. I get &quot;Unable to read all metrics&quot;.</p>
<p>I'm not sure why? Do I need to add specific permissions in my serviceaccount? Or do I need to use a Custom Metrics Adapter? Does the HPA not have access without a adapter?</p>
<p>I have even tried to add the full name path for the metric name, but I get an error that &quot;/&quot; is not allowed in the name.</p>
<p>I would appreciate any help!</p>

user11122042
<p>Indeed, you need to deploy a metric server, please refer to this <a href="https://github.com/kubernetes-sigs/metrics-server" rel="nofollow noreferrer">link</a>. And bear in mind that it works for cpu and memory.</p>
<ol>
<li><strong>CPU and Memory HPA</strong></li>
</ol>
<p><strong>Notice:</strong></p>
<p>Kubelet certificate needs to be signed by cluster Certificate Authority (<strong>or disable certificate validation by passing --kubelet-insecure-tls to Metrics Server</strong>)
So add under args (you will get some headaches and TLS can be added later):</p>
<pre><code>- --kubelet-insecure-tls
</code></pre>
<ol start="2">
<li><strong>Custom metrics</strong></li>
</ol>
<p><strong>Notice:</strong> Before reading below check this <a href="https://kubernetes.io/docs/tasks/run-application/horizontal-pod-autoscale-walkthrough/#autoscaling-on-multiple-metrics-and-custom-metrics" rel="nofollow noreferrer">out</a>.</p>
<p>This will require some custom resource definition as well as adapter, metrics api. This video might help A LOT :)</p>
<p><a href="https://www.youtube.com/watch?v=iodq-4srXA8&amp;t=550s" rel="nofollow noreferrer">https://www.youtube.com/watch?v=iodq-4srXA8&amp;t=550s</a></p>
<p>Bonus track: do not hesitate to use siege to stress the pods, also i would try scale up and scale down :)</p>
