Skip to content
Advertisement

How to reference a CloudWatch metric created by container insights for EKS?

I saw an example, how it is possible to make a reference on ECS: How to reference a CloudWatch metric created by container insights for ECS/Fargate

My goal is to make it similiar for EKS, to get “ContainerInsights” like Utilization, Memory etc.

I would be happy, if someone could show me an example. Thanks.

Advertisement

Answer

You can access any metric published by CloudWatch by instantiating a Metric object. The list of EKS Container Insights metrics can be found in the docs.

So, for example,

new cloudwatch.Metric({
  metricName: 'node_cpu_usage_total',
  namespace: 'ContainerInsights',

  // if your EKS cluster is defined in CDK, you can also reference the 
  // dimensions dynamically (instead of hardcoding as shown in this example)
  dimensions: { ClusterName: 'MyCluster', NodeName: 'MyNode' },
});

You can always look at the metrics in the CloudWatch Metrics Explorer to discover the proper metric names and dimensions to use.

User contributions licensed under: CC BY-SA
10 People found this is helpful
Advertisement