<p>I am working on EKS cluster in AWS. We have an application, which is memory intensive. Because of that, I have added an HPA, which has 60% memory utilization. We would like to have only this info in cloudwatch, so we can scale our servers accordingly.  I tried container insights, but it's an overkill.</p>
<p><strong>Is there any way to get Kubernetes HPA logs in cloudwatch as events?</strong></p>
<p>HPA :</p>
<pre><code>apiVersion: autoscaling/v2beta2
kind: HorizontalPodAutoscaler
metadata:
  name: resize-hpa
spec:
  scaleTargetRef:
    apiVersion: apps/v1beta1
    kind: Deployment
    name: magento-prod-deployment
  minReplicas: 2
  maxReplicas: 5
  metrics:
  - type: Resource
    resource:
      name: memory 
      target:
        type: Utilization 
        averageUtilization: 60
</code></pre>
<p>Versions :</p>
<pre><code> kubectl version
Client Version: version.Info{Major:&quot;1&quot;, Minor:&quot;18&quot;, GitVersion:&quot;v1.18.8&quot;, GitCommit:&quot;9f2892aab98fe339f3bd70e3c470144299398ace&quot;, GitTreeState:&quot;clean&quot;, BuildDate:&quot;2020-08-26T20:32:49Z&quot;, GoVersion:&quot;go1.13.15&quot;, Compiler:&quot;gc&quot;, Platform:&quot;linux/amd64&quot;}
Server Version: version.Info{Major:&quot;1&quot;, Minor:&quot;15+&quot;, GitVersion:&quot;v1.15.11-eks-065dce&quot;, GitCommit:&quot;065dcecfcd2a91bd68a17ee0b5e895088430bd05&quot;, GitTreeState:&quot;clean&quot;, BuildDate:&quot;2020-07-16T01:44:47Z&quot;, GoVersion:&quot;go1.12.17&quot;, Compiler:&quot;gc&quot;, Platform:&quot;linux/amd64&quot;}
</code></pre>
<p>EKS cluster is running on 1.15</p>

We are Borg
<p>I believe you can use <code>k8s-cloudwatch-adapter</code> for your needs.
<a href="https://aws.amazon.com/blogs/compute/scaling-kubernetes-deployments-with-amazon-cloudwatch-metrics/" rel="nofollow noreferrer">Scaling Kubernetes deployments with Amazon CloudWatch metrics</a> documentation provides the info on how <code>k8s-cloudwatch-adapter</code> works, how you can install and use it.</p>
<blockquote>
<p>Amazon CloudWatch Metrics Adapter for Kubernetes</p>
<p>The k8s-cloudwatch-adapter is an implementation of the Kubernetes
Custom Metrics API and External Metrics API with integration for
CloudWatch metrics. It allows you to scale your Kubernetes deployment
using the Horizontal Pod Autoscaler (HPA) with CloudWatch metrics.</p>
</blockquote>
<p><a href="https://github.com/awslabs/k8s-cloudwatch-adapter" rel="nofollow noreferrer">k8s-cloudwatch-adapter github</a></p>
<p>Please also look into <a href="https://stackoverflow.com/questions/63604513/kubernetes-aws-cloudwatch-adapter-not-fetching-custom-metric-value-for-eks-hpa-a">Kubernetes AWS Cloudwatch adapter not fetching custom metric value for EKS HPA autoscaling</a> - already good example on how to enable AWS EKS autoscaling based on a custom Cloudwatch metric</p>
