<p>I have this JSON code:</p>
<pre class="lang-json prettyprint-override"><code>{
    &quot;apiVersion&quot;: &quot;autoscaling/v1&quot;,
    &quot;kind&quot;: &quot;HorizontalPodAutoscaler&quot;,
    &quot;metadata&quot;: {
        &quot;annotations&quot;: {
            &quot;autoscaling.alpha.kubernetes.io/metrics&quot;: &quot;[{\&quot;type\&quot;:\&quot;Resource\&quot;,\&quot;resource\&quot;:{\&quot;name\&quot;:\&quot;memory\&quot;,\&quot;targetAverageValue\&quot;:\&quot;400Mi\&quot;}}]&quot;,
            &quot;kubectl.kubernetes.io/last-applied-configuration&quot;: &quot;{\&quot;apiVersion\&quot;:\&quot;autoscaling/v2beta1\&quot;,\&quot;kind\&quot;:\&quot;HorizontalPodAutoscaler\&quot;,\&quot;metadata\&quot;:{\&quot;annotations\&quot;:{},\&quot;name\&quot;:\&quot;pdn-location-suscriber\&quot;,\&quot;namespace\&quot;:\&quot;pdn-oms\&quot;},\&quot;spec\&quot;:{\&quot;maxReplicas\&quot;:3,\&quot;metrics\&quot;:[{\&quot;resource\&quot;:{\&quot;name\&quot;:\&quot;cpu\&quot;,\&quot;targetAverageUtilization\&quot;:100},\&quot;type\&quot;:\&quot;Resource\&quot;},{\&quot;resource\&quot;:{\&quot;name\&quot;:\&quot;memory\&quot;,\&quot;targetAverageValue\&quot;:\&quot;400Mi\&quot;},\&quot;type\&quot;:\&quot;Resource\&quot;}],\&quot;minReplicas\&quot;:1,\&quot;scaleTargetRef\&quot;:{\&quot;apiVersion\&quot;:\&quot;extensions/v1beta1\&quot;,\&quot;kind\&quot;:\&quot;Deployment\&quot;,\&quot;name\&quot;:\&quot;location-suscriber\&quot;}}}\n&quot;
        }
    }
}
</code></pre>
<p>I need to obtain the value of <code>targetAverageValue = 400Mi</code> that is in <code>&quot;autoscaling.alpha.kubernetes.io/metrics&quot;</code>, so how create a JSONPath expression to extract that.</p>

Jorge Luis Higuita Isaza
<p>You can actually use this expression to get your desired value.</p>
<pre><code>kubectl get hpa pdn-location-suscriber(your_hpa_name) -n pdn-oms -o jsonpath=&quot;{.spec.metrics[1].resource.targetAverageValue}&quot;
</code></pre>
<p>which means jsonpath expression:</p>
<pre><code>jsonpath=&quot;{.spec.metrics[1].resource.targetAverageValue}&quot;

</code></pre>
<p>as you have metrics under spec which is a list you have to use index number which is 1 in this case.</p>
