CloudWatchAgentIntegration
- class aws_cdk.aws_applicationsignals_alpha.CloudWatchAgentIntegration(scope, id, *, task_definition, container_name, agent_config=None, cpu=None, enable_logging=None, essential=None, memory_limit_mib=None, memory_reservation_mib=None, operating_system_family=None, port_mappings=None)
Bases:
Construct(experimental) A construct that adds CloudWatch Agent as a container to an ECS task definition.
- Stability:
experimental
- ExampleMetadata:
infused
Example:
from constructs import Construct import aws_cdk.aws_applicationsignals_alpha as appsignals import aws_cdk as cdk import aws_cdk.aws_ec2 as ec2 import aws_cdk.aws_ecs as ecs class MyStack(cdk.Stack): def __init__(self, scope=None, id=None, *, description=None, env=None, stackName=None, tags=None, notificationArns=None, synthesizer=None, terminationProtection=None, analyticsReporting=None, crossRegionReferences=None, permissionsBoundary=None, suppressTemplateIndentation=None, propertyInjectors=None): super().__init__(scope, id, description=description, env=env, stackName=stackName, tags=tags, notificationArns=notificationArns, synthesizer=synthesizer, terminationProtection=terminationProtection, analyticsReporting=analyticsReporting, crossRegionReferences=crossRegionReferences, permissionsBoundary=permissionsBoundary, suppressTemplateIndentation=suppressTemplateIndentation, propertyInjectors=propertyInjectors) vpc = ec2.Vpc(self, "TestVpc") cluster = ecs.Cluster(self, "TestCluster", vpc=vpc) # Define Task Definition for CloudWatch agent (Daemon) cw_agent_task_definition = ecs.Ec2TaskDefinition(self, "CloudWatchAgentTaskDefinition", network_mode=ecs.NetworkMode.HOST ) appsignals.CloudWatchAgentIntegration(self, "CloudWatchAgentIntegration", task_definition=cw_agent_task_definition, container_name="ecs-cwagent", enable_logging=False, cpu=128, memory_limit_mi_b=64, port_mappings=[ecs.PortMapping( container_port=4316, host_port=4316 ), ecs.PortMapping( container_port=2000, host_port=2000 ) ] ) # Create the CloudWatch Agent daemon service ecs.Ec2Service(self, "CloudWatchAgentDaemon", cluster=cluster, task_definition=cw_agent_task_definition, daemon=True ) # Define Task Definition for user application sample_app_task_definition = ecs.Ec2TaskDefinition(self, "SampleAppTaskDefinition", network_mode=ecs.NetworkMode.HOST ) sample_app_task_definition.add_container("app", image=ecs.ContainerImage.from_registry("test/sample-app"), cpu=0, memory_limit_mi_b=512 ) # No CloudWatch Agent side car is needed as application container communicates to CloudWatch Agent daemon through host network appsignals.ApplicationSignalsIntegration(self, "ApplicationSignalsIntegration", task_definition=sample_app_task_definition, instrumentation=appsignals.InstrumentationProps( sdk_version=appsignals.PythonInstrumentationVersion.V0_8_0 ), service_name="sample-app" ) ecs.Ec2Service(self, "MySampleApp", cluster=cluster, task_definition=sample_app_task_definition, desired_count=1 )
(experimental) Creates a new CloudWatch Agent integration.
- Parameters:
scope (
Construct) –The construct scope.
id (
str) –The construct ID.
task_definition (
TaskDefinition) – (experimental) The task definition to integrate CloudWatch agent into. [disable-awslint:ref-via-interface]container_name (
str) – (experimental) Name of the CloudWatch Agent container.agent_config (
Optional[str]) – (experimental) Custom agent configuration in JSON format. Default: - Uses default configuration for Application Signalscpu (
Union[int,float,None]) – (experimental) The minimum number of CPU units to reserve for the container. Default: - No minimum CPU units reserved.enable_logging (
Optional[bool]) – (experimental) Whether to enable logging for the CloudWatch Agent. Default: - falseessential (
Optional[bool]) – (experimental) Start as an essential container. Default: - truememory_limit_mib (
Union[int,float,None]) – (experimental) The amount (in MiB) of memory to present to the container. Default: - No memory limit.memory_reservation_mib (
Union[int,float,None]) – (experimental) The soft limit (in MiB) of memory to reserve for the container. Default: - No memory reserved.operating_system_family (
Optional[OperatingSystemFamily]) – (experimental) Operating system family for the CloudWatch Agent. Default: - Linuxport_mappings (
Optional[Sequence[Union[PortMapping,Dict[str,Any]]]]) – (experimental) The port mappings to add to the container definition. Default: - No ports are mapped.
- Stability:
experimental
Methods
- to_string()
Returns a string representation of this construct.
- Return type:
str
Attributes
- agent_container
(experimental) The CloudWatch Agent container definition.
- Stability:
experimental
- node
The tree node.
Static Methods
- classmethod is_construct(x)
Checks if
xis a construct.Use this method instead of
instanceofto properly detectConstructinstances, even when the construct library is symlinked.Explanation: in JavaScript, multiple copies of the
constructslibrary on disk are seen as independent, completely different libraries. As a consequence, the classConstructin each copy of theconstructslibrary is seen as a different class, and an instance of one class will not test asinstanceofthe other class.npm installwill not create installations like this, but users may manually symlink construct libraries together or use a monorepo tool: in those cases, multiple copies of theconstructslibrary can be accidentally installed, andinstanceofwill behave unpredictably. It is safest to avoid usinginstanceof, and using this type-testing method instead.- Parameters:
x (
Any) – Any object.- Return type:
bool- Returns:
true if
xis an object created from a class which extendsConstruct.