Show / Hide Table of Contents

Class CloudWatchAgentIntegration

(experimental) A construct that adds CloudWatch Agent as a container to an ECS task definition.

Inheritance
object
CloudWatchAgentIntegration
Namespace: Amazon.CDK.AWS.ApplicationSignals.Alpha
Assembly: Amazon.CDK.AWS.ApplicationSignals.Alpha.dll
Syntax (csharp)
public class CloudWatchAgentIntegration : Construct
Syntax (vb)
Public Class CloudWatchAgentIntegration Inherits Construct
Remarks

Stability: Experimental

ExampleMetadata: infused

Examples
using Constructs;
             using Amazon.CDK.AWS.ApplicationSignals.Alpha;
             using Amazon.CDK;
             using Amazon.CDK.AWS.EC2;
             using Amazon.CDK.AWS.ECS;

             class MyStack : Stack
             {
                 public MyStack(Construct? scope=null, string? id=null, StackProps props=new StackProps { }) : base(scope, id, props)
                 {

                     var vpc = new Vpc(this, "TestVpc", new VpcProps { });
                     var cluster = new Cluster(this, "TestCluster", new ClusterProps { Vpc = vpc });

                     // Define Task Definition for CloudWatch agent (Daemon)
                     var cwAgentTaskDefinition = new Ec2TaskDefinition(this, "CloudWatchAgentTaskDefinition", new Ec2TaskDefinitionProps {
                         NetworkMode = NetworkMode.HOST
                     });

                     new CloudWatchAgentIntegration(this, "CloudWatchAgentIntegration", new CloudWatchAgentIntegrationProps {
                         TaskDefinition = cwAgentTaskDefinition,
                         ContainerName = "ecs-cwagent",
                         EnableLogging = false,
                         Cpu = 128,
                         MemoryLimitMiB = 64,
                         PortMappings = new [] { new PortMapping {
                             ContainerPort = 4316,
                             HostPort = 4316
                         }, new PortMapping {
                             ContainerPort = 2000,
                             HostPort = 2000
                         } }
                     });

                     // Create the CloudWatch Agent daemon service
                     // Create the CloudWatch Agent daemon service
                     new Ec2Service(this, "CloudWatchAgentDaemon", new Ec2ServiceProps {
                         Cluster = cluster,
                         TaskDefinition = cwAgentTaskDefinition,
                         Daemon = true
                     });

                     // Define Task Definition for user application
                     var sampleAppTaskDefinition = new Ec2TaskDefinition(this, "SampleAppTaskDefinition", new Ec2TaskDefinitionProps {
                         NetworkMode = NetworkMode.HOST
                     });

                     sampleAppTaskDefinition.AddContainer("app", new ContainerDefinitionOptions {
                         Image = ContainerImage.FromRegistry("test/sample-app"),
                         Cpu = 0,
                         MemoryLimitMiB = 512
                     });

                     // No CloudWatch Agent side car is needed as application container communicates to CloudWatch Agent daemon through host network
                     // No CloudWatch Agent side car is needed as application container communicates to CloudWatch Agent daemon through host network
                     new ApplicationSignalsIntegration(this, "ApplicationSignalsIntegration", new ApplicationSignalsIntegrationProps {
                         TaskDefinition = sampleAppTaskDefinition,
                         Instrumentation = new InstrumentationProps {
                             SdkVersion = PythonInstrumentationVersion.V0_8_0
                         },
                         ServiceName = "sample-app"
                     });

                     new Ec2Service(this, "MySampleApp", new Ec2ServiceProps {
                         Cluster = cluster,
                         TaskDefinition = sampleAppTaskDefinition,
                         DesiredCount = 1
                     });
                 }
             }

Synopsis

Constructors

CloudWatchAgentIntegration(Construct, string, ICloudWatchAgentIntegrationProps)

(experimental) Creates a new CloudWatch Agent integration.

Properties

AgentContainer

(experimental) The CloudWatch Agent container definition.

Constructors

CloudWatchAgentIntegration(Construct, string, ICloudWatchAgentIntegrationProps)

(experimental) Creates a new CloudWatch Agent integration.

public CloudWatchAgentIntegration(Construct scope, string id, ICloudWatchAgentIntegrationProps props)
Parameters
scope Construct
  • The construct scope.
id string
  • The construct ID.
props ICloudWatchAgentIntegrationProps
  • Configuration properties.
Remarks

Stability: Experimental

Properties

AgentContainer

(experimental) The CloudWatch Agent container definition.

public virtual ContainerDefinition AgentContainer { get; }
Property Value

ContainerDefinition

Remarks

Stability: Experimental

Back to top Generated by DocFX