awslabs.cloudwatch-applicationsignals-mcp-server 0.1.21__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (36) hide show
  1. awslabs/__init__.py +17 -0
  2. awslabs/cloudwatch_applicationsignals_mcp_server/__init__.py +17 -0
  3. awslabs/cloudwatch_applicationsignals_mcp_server/audit_presentation_utils.py +288 -0
  4. awslabs/cloudwatch_applicationsignals_mcp_server/audit_utils.py +912 -0
  5. awslabs/cloudwatch_applicationsignals_mcp_server/aws_clients.py +120 -0
  6. awslabs/cloudwatch_applicationsignals_mcp_server/canary_utils.py +910 -0
  7. awslabs/cloudwatch_applicationsignals_mcp_server/enablement_guides/templates/ec2/ec2-dotnet-enablement.md +435 -0
  8. awslabs/cloudwatch_applicationsignals_mcp_server/enablement_guides/templates/ec2/ec2-java-enablement.md +321 -0
  9. awslabs/cloudwatch_applicationsignals_mcp_server/enablement_guides/templates/ec2/ec2-nodejs-enablement.md +420 -0
  10. awslabs/cloudwatch_applicationsignals_mcp_server/enablement_guides/templates/ec2/ec2-python-enablement.md +598 -0
  11. awslabs/cloudwatch_applicationsignals_mcp_server/enablement_guides/templates/ecs/ecs-dotnet-enablement.md +264 -0
  12. awslabs/cloudwatch_applicationsignals_mcp_server/enablement_guides/templates/ecs/ecs-java-enablement.md +193 -0
  13. awslabs/cloudwatch_applicationsignals_mcp_server/enablement_guides/templates/ecs/ecs-nodejs-enablement.md +198 -0
  14. awslabs/cloudwatch_applicationsignals_mcp_server/enablement_guides/templates/ecs/ecs-python-enablement.md +236 -0
  15. awslabs/cloudwatch_applicationsignals_mcp_server/enablement_guides/templates/eks/eks-dotnet-enablement.md +166 -0
  16. awslabs/cloudwatch_applicationsignals_mcp_server/enablement_guides/templates/eks/eks-java-enablement.md +166 -0
  17. awslabs/cloudwatch_applicationsignals_mcp_server/enablement_guides/templates/eks/eks-nodejs-enablement.md +166 -0
  18. awslabs/cloudwatch_applicationsignals_mcp_server/enablement_guides/templates/eks/eks-python-enablement.md +169 -0
  19. awslabs/cloudwatch_applicationsignals_mcp_server/enablement_guides/templates/lambda/lambda-dotnet-enablement.md +336 -0
  20. awslabs/cloudwatch_applicationsignals_mcp_server/enablement_guides/templates/lambda/lambda-java-enablement.md +336 -0
  21. awslabs/cloudwatch_applicationsignals_mcp_server/enablement_guides/templates/lambda/lambda-nodejs-enablement.md +336 -0
  22. awslabs/cloudwatch_applicationsignals_mcp_server/enablement_guides/templates/lambda/lambda-python-enablement.md +336 -0
  23. awslabs/cloudwatch_applicationsignals_mcp_server/enablement_tools.py +147 -0
  24. awslabs/cloudwatch_applicationsignals_mcp_server/server.py +1505 -0
  25. awslabs/cloudwatch_applicationsignals_mcp_server/service_audit_utils.py +231 -0
  26. awslabs/cloudwatch_applicationsignals_mcp_server/service_tools.py +659 -0
  27. awslabs/cloudwatch_applicationsignals_mcp_server/sli_report_client.py +333 -0
  28. awslabs/cloudwatch_applicationsignals_mcp_server/slo_tools.py +386 -0
  29. awslabs/cloudwatch_applicationsignals_mcp_server/trace_tools.py +784 -0
  30. awslabs/cloudwatch_applicationsignals_mcp_server/utils.py +172 -0
  31. awslabs_cloudwatch_applicationsignals_mcp_server-0.1.21.dist-info/METADATA +808 -0
  32. awslabs_cloudwatch_applicationsignals_mcp_server-0.1.21.dist-info/RECORD +36 -0
  33. awslabs_cloudwatch_applicationsignals_mcp_server-0.1.21.dist-info/WHEEL +4 -0
  34. awslabs_cloudwatch_applicationsignals_mcp_server-0.1.21.dist-info/entry_points.txt +2 -0
  35. awslabs_cloudwatch_applicationsignals_mcp_server-0.1.21.dist-info/licenses/LICENSE +174 -0
  36. awslabs_cloudwatch_applicationsignals_mcp_server-0.1.21.dist-info/licenses/NOTICE +2 -0
@@ -0,0 +1,435 @@
1
+ # Task: Enable AWS Application Signals for .NET on EC2
2
+
3
+ Your task is to modify Infrastructure as Code (IaC) files to enable AWS Application Signals for a .NET application running on EC2 instances. You will update IAM permissions, install monitoring agents, and configure OpenTelemetry instrumentation through UserData scripts.
4
+
5
+ ## What You Will Accomplish
6
+
7
+ After completing this task:
8
+ - The EC2 instance will have permissions to send telemetry data to CloudWatch
9
+ - The CloudWatch Agent will be installed and configured for Application Signals
10
+ - The .NET application will be automatically instrumented with AWS Distro for OpenTelemetry (ADOT)
11
+ - Traces, metrics, and performance data will appear in the CloudWatch Application Signals console
12
+ - The user will be able to see service maps, SLOs, and application performance metrics without manual code instrumentation
13
+
14
+ ## Critical Requirements
15
+
16
+ **Error Handling:**
17
+ - If you cannot determine required values from the IaC, STOP and ask the user
18
+ - For multiple EC2 instances, ask which one(s) to modify
19
+ - Preserve all existing UserData commands; add new ones in sequence
20
+
21
+ **Do NOT:**
22
+ - Run deployment commands automatically (`cdk deploy`, `terraform apply`, etc.)
23
+ - Remove existing application startup logic
24
+ - Skip the user approval step before deployment
25
+
26
+ ## IaC Tool Support
27
+
28
+ **Code examples use CDK TypeScript syntax.** If you are working with Terraform or CloudFormation, translate the CDK syntax to the appropriate format while keeping all bash commands identical. The UserData bash commands (CloudWatch Agent installation, ADOT installation, environment variables) are universal across all IaC tools - only the wrapper syntax differs.
29
+
30
+ ## Before You Start: Gather Required Information
31
+
32
+ Execute these steps to collect the information needed for configuration:
33
+
34
+ ### Step 1: Determine Deployment Type
35
+
36
+ Read the UserData script and look for the application startup command. This is typically one of the last commands in UserData.
37
+
38
+ **If you see:**
39
+ - `docker run` or `docker start` → Docker deployment
40
+ - `dotnet run`, `dotnet myapp.dll`, or similar → Non-Docker deployment
41
+
42
+ **If unclear:**
43
+ - Ask the user: "Is your .NET application running in a Docker container or directly on the EC2 instance?" DO NOT GUESS
44
+
45
+ **Critical distinction:** Where does the .NET process run?
46
+ - **Docker:** .NET runs inside a container → Modify Dockerfile
47
+ - **Non-Docker:** .NET runs directly on EC2 → Modify UserData
48
+
49
+ ### Step 2: Extract Placeholder Values
50
+
51
+ Analyze the existing IaC to determine these values for Application Signals enablement:
52
+
53
+ - `{{SERVICE_NAME}}`
54
+ - **Why It Matters:** Sets the service name displayed in Application Signals console via `OTEL_RESOURCE_ATTRIBUTES=service.name={{SERVICE_NAME}}`
55
+ - **How to Find It:** Use the application name, stack name, or construct ID. Look for service/app names in the IaC.
56
+ - **Example Value:** `my-dotnet-app`
57
+ - **Required For:** Both Docker and non-Docker
58
+
59
+ For Docker-based deployments you will also need to find these additional values:
60
+
61
+ - `{{PORT}}`
62
+ - **Why It Matters:** Docker port mapping that ensures the container is accessible on the correct port
63
+ - **How to Find It:** Find port mappings in `docker run -p` commands or security group ingress rules
64
+ - **Example Value:** `8080`
65
+ - **Required For:** Docker
66
+ - `{{APP_NAME}}`
67
+ - **Why It Matters:** Used to reference the container for operations like `docker logs {{APP_NAME}}`, `docker exec`, health checks, etc.
68
+ - **How to Find It:** Find container name in `docker run --name` or use `{{SERVICE_NAME}}-container`
69
+ - **Example Value:** `dotnet-api-app`
70
+ - **Required For:** Docker
71
+ - `{{IMAGE_URI}}`
72
+ - **Why It Matters:** This is the identifier for the application that Docker will run
73
+ - **How to Find It:** Find the Docker image in `docker run` or `docker pull` commands
74
+ - **Example Value:** `123456789012.dkr.ecr.us-east-1.amazonaws.com/my-app:latest`
75
+ - **Required For:** Docker
76
+
77
+ **If you cannot determine a value:** Ask the user for clarification before proceeding. Do not guess or make up values.
78
+
79
+ ### Step 3: Identify Instance OS
80
+
81
+ Determine the operating system to use the correct installation commands.
82
+
83
+ **Linux:**
84
+ - **Amazon Linux 2:** Use `yum` package manager
85
+ - **Amazon Linux 2023:** Use `dnf` package manager
86
+ - **Ubuntu/Debian:** Use `apt` package manager
87
+ - **How to detect:** Look for existing package install commands in UserData (check for `yum`, `dnf`, or `apt`), or look for AMI references containing `al2`, `al2023`, `ubuntu`, etc.
88
+
89
+ **Windows Server:**
90
+ - **Not supported yet.** If the customer is using Windows Server-based EC2 instances, inform them that automated enablement is not available yet. Provide them with this link to enable Application Signals manually: https://docs.aws.amazon.com/AmazonCloudWatch/latest/monitoring/CloudWatch-Application-Signals-Enable-EC2Main.html
91
+
92
+ **If unclear:** Look for AMI name/ID in the IaC or ask the user which OS the EC2 instance is running. Do not guess or make up values.
93
+
94
+ ## Instructions
95
+
96
+ Follow these steps in sequence:
97
+
98
+ ### Step 1: Locate the IaC Files
99
+
100
+ **Search for EC2 instance definitions** using these patterns:
101
+
102
+ **CDK:**
103
+ ```
104
+ new ec2.Instance(
105
+ ec2.Instance(
106
+ CfnInstance(
107
+ ```
108
+
109
+ **Terraform:**
110
+ ```
111
+ resource "aws_instance"
112
+ ```
113
+
114
+ **CloudFormation:**
115
+ ```
116
+ AWS::EC2::Instance
117
+ ```
118
+
119
+ **Read the file(s)** containing the EC2 instance definition. You need to identify:
120
+ 1. The instance resource/construct
121
+ 2. The IAM role attached to the instance
122
+ 3. The UserData script or property
123
+
124
+ ### Step 2: Locate the IAM Role
125
+
126
+ Find the IAM role attached to the EC2 instance
127
+
128
+ **CDK:**
129
+ ```typescript
130
+ role: someRole
131
+ new iam.Role(this, 'RoleName'
132
+ ```
133
+
134
+ ### Step 3: Update the IAM Role
135
+
136
+ Add the CloudWatch Agent Server Policy to the IAM role's managed policies.
137
+
138
+ **CDK:**
139
+ ```typescript
140
+ const role = new iam.Role(this, 'AppRole', {
141
+ assumedBy: new iam.ServicePrincipal('ec2.amazonaws.com'),
142
+ managedPolicies: [
143
+ iam.ManagedPolicy.fromAwsManagedPolicyName('CloudWatchAgentServerPolicy'),
144
+ // ... keep existing policies
145
+ ],
146
+ });
147
+ ```
148
+
149
+ ### Step 4: Modify UserData - Add Prerequisites
150
+
151
+ Add a CloudWatch Agent installation command to the UserData script.
152
+
153
+ **CRITICAL for Terraform Users:** When modifying Terraform `user_data` heredocs, you MUST preserve the EXACT indentation of existing lines. Terraform's `<<-EOF` syntax strips leading whitespace, but only if indentation is consistent. When adding new bash commands:
154
+ - Count the leading spaces/tabs on existing lines in the heredoc
155
+ - Apply the SAME amount of leading whitespace to all new lines you add
156
+ - Do NOT modify the indentation of any existing lines
157
+
158
+ If indentation is inconsistent, Terraform will NOT strip the whitespace, causing the deployed script to have leading spaces before `#!/bin/bash`, which will cause cloud-init to fail.
159
+
160
+ **For Linux instances:**
161
+
162
+ **CDK TypeScript example:**
163
+ ```typescript
164
+ instance.userData.addCommands(
165
+ 'dnf install -y amazon-cloudwatch-agent', // Use dnf for AL2023, yum for AL2, apt-get for Ubuntu
166
+ // ... rest of UserData follows
167
+ );
168
+ ```
169
+
170
+ **Placement:** Add this command early in the UserData script:
171
+ - If system update commands exist (like `dnf update -y`, `apt-get update`), add it immediately after those
172
+ - If no system update commands exist, add it at the very beginning of UserData
173
+ - This should come before any application dependency installations or application setup commands
174
+
175
+ **For Windows instances:**
176
+
177
+ **CDK TypeScript example:**
178
+ ```typescript
179
+ instance.userData.addCommands(
180
+ '# Download and install CloudWatch Agent',
181
+ 'Invoke-WebRequest -Uri "https://amazoncloudwatch-agent.s3.amazonaws.com/windows/amd64/latest/amazon-cloudwatch-agent.msi" -OutFile "C:\\amazon-cloudwatch-agent.msi"',
182
+ 'Start-Process msiexec.exe -Wait -ArgumentList "/i C:\\amazon-cloudwatch-agent.msi /quiet"',
183
+ 'Remove-Item "C:\\amazon-cloudwatch-agent.msi"',
184
+ // ... rest of UserData follows
185
+ );
186
+ ```
187
+
188
+ **Placement:** Add these commands early in the UserData script, before any application setup commands.
189
+
190
+ **For other Linux distributions:** CloudWatch Agent may not be available via the OS package manager. Refer to [AWS CloudWatch Agent installation docs](https://docs.aws.amazon.com/AmazonCloudWatch/latest/monitoring/manual-installation.html) for distribution-specific instructions.
191
+
192
+ ### Step 5: Modify UserData - Configure CloudWatch Agent
193
+
194
+ The CloudWatch Agent was installed in Step 4. Now configure it for Application Signals:
195
+
196
+ **For Linux instances:**
197
+
198
+ **CDK TypeScript example:**
199
+ ```typescript
200
+ instance.userData.addCommands(
201
+ '# Create CloudWatch Agent configuration for Application Signals',
202
+ "cat > /opt/aws/amazon-cloudwatch-agent/etc/amazon-cloudwatch-agent.json << 'EOF'",
203
+ '{',
204
+ ' "traces": {',
205
+ ' "traces_collected": {',
206
+ ' "application_signals": {}',
207
+ ' }',
208
+ ' },',
209
+ ' "logs": {',
210
+ ' "metrics_collected": {',
211
+ ' "application_signals": {}',
212
+ ' }',
213
+ ' }',
214
+ '}',
215
+ 'EOF',
216
+ '',
217
+ '# Start CloudWatch Agent with Application Signals configuration',
218
+ '/opt/aws/amazon-cloudwatch-agent/bin/amazon-cloudwatch-agent-ctl \\',
219
+ ' -a fetch-config \\',
220
+ ' -m ec2 \\',
221
+ ' -s \\',
222
+ ' -c file:/opt/aws/amazon-cloudwatch-agent/etc/amazon-cloudwatch-agent.json',
223
+ );
224
+ ```
225
+
226
+ **For Windows instances:**
227
+
228
+ **CDK TypeScript example:**
229
+ ```typescript
230
+ instance.userData.addCommands(
231
+ '# Create CloudWatch Agent configuration for Application Signals',
232
+ '@"',
233
+ '{',
234
+ ' "traces": {',
235
+ ' "traces_collected": {',
236
+ ' "application_signals": {}',
237
+ ' }',
238
+ ' },',
239
+ ' "logs": {',
240
+ ' "metrics_collected": {',
241
+ ' "application_signals": {}',
242
+ ' }',
243
+ ' }',
244
+ '}',
245
+ '"@ | Out-File -FilePath "C:\\ProgramData\\Amazon\\AmazonCloudWatchAgent\\amazon-cloudwatch-agent.json" -Encoding ASCII',
246
+ '',
247
+ '# Start CloudWatch Agent with Application Signals configuration',
248
+ '& "C:\\Program Files\\Amazon\\AmazonCloudWatchAgent\\amazon-cloudwatch-agent-ctl.ps1" -a fetch-config -m ec2 -s -c file:"C:\\ProgramData\\Amazon\\AmazonCloudWatchAgent\\amazon-cloudwatch-agent.json"',
249
+ );
250
+ ```
251
+
252
+ ### Step 6: Install ADOT .NET Auto-Instrumentation
253
+
254
+ Choose based on deployment type and OS identified in "Before You Start".
255
+
256
+ #### Option A: Docker Deployment - Modify Dockerfile
257
+
258
+ For Docker deployments, modify the `Dockerfile` in the application directory.
259
+
260
+ **For Linux-based containers:**
261
+
262
+ Add these lines to install the ADOT .NET auto-instrumentation. Place this AFTER any `RUN` commands that install dependencies, but BEFORE the `CMD` line:
263
+
264
+ ```dockerfile
265
+ # Install unzip (required by ADOT installation script)
266
+ # Use the appropriate package manager for your base image:
267
+ # - For Amazon Linux 2: RUN yum install -y unzip
268
+ # - For Amazon Linux 2023: RUN dnf install -y unzip
269
+ # - For Ubuntu/Debian: RUN apt-get update && apt-get install -y unzip
270
+ RUN dnf install -y unzip # Adjust package manager as needed
271
+
272
+ # Download and install ADOT .NET auto-instrumentation to /opt (accessible by all users)
273
+ RUN curl -L -O https://github.com/aws-observability/aws-otel-dotnet-instrumentation/releases/latest/download/aws-otel-dotnet-install.sh \
274
+ && chmod +x ./aws-otel-dotnet-install.sh \
275
+ && OTEL_DOTNET_AUTO_HOME="/opt/otel-dotnet-auto" ./aws-otel-dotnet-install.sh \
276
+ && chmod -R 755 /opt/otel-dotnet-auto
277
+ ```
278
+
279
+ **Why modify Dockerfile, not UserData:** The ADOT instrumentation must be available inside the container image, not on the EC2 host. UserData commands run on the host and won't affect the containerized application.
280
+
281
+ #### Option B: Non-Docker Deployment - Modify UserData
282
+
283
+ **For Linux instances:**
284
+
285
+ For non-Docker deployments, add to UserData AFTER CloudWatch Agent configuration:
286
+
287
+ ```typescript
288
+ instance.userData.addCommands(
289
+ '# Install unzip (required by ADOT installation script)',
290
+ 'dnf install -y unzip', // Use dnf for AL2023, yum for AL2, apt-get for Ubuntu
291
+ '',
292
+ '# Download and install ADOT .NET auto-instrumentation to /opt',
293
+ 'curl -L -O https://github.com/aws-observability/aws-otel-dotnet-instrumentation/releases/latest/download/aws-otel-dotnet-install.sh',
294
+ 'chmod +x ./aws-otel-dotnet-install.sh',
295
+ 'OTEL_DOTNET_AUTO_HOME="/opt/otel-dotnet-auto" ./aws-otel-dotnet-install.sh',
296
+ 'chmod -R 755 /opt/otel-dotnet-auto',
297
+ );
298
+ ```
299
+
300
+ **For Windows instances:**
301
+
302
+ For non-Docker deployments, add to UserData AFTER CloudWatch Agent configuration:
303
+
304
+ ```typescript
305
+ instance.userData.addCommands(
306
+ '# Download and install ADOT .NET auto-instrumentation',
307
+ '$module_url = "https://github.com/aws-observability/aws-otel-dotnet-instrumentation/releases/latest/download/AWS.Otel.DotNet.Auto.psm1"',
308
+ '$download_path = Join-Path $env:temp "AWS.Otel.DotNet.Auto.psm1"',
309
+ 'Invoke-WebRequest -Uri $module_url -OutFile $download_path',
310
+ 'Import-Module $download_path',
311
+ 'Install-OpenTelemetryCore',
312
+ );
313
+ ```
314
+
315
+ ### Step 7: Modify UserData - Configure Application
316
+
317
+ Choose based on deployment type and OS identified in "Before You Start".
318
+
319
+ #### Option A: Docker Deployment
320
+
321
+ **Critical Docker configuration:** The `--network host` flag is REQUIRED for all Docker deployments on Linux. Without it, the container cannot reach the CloudWatch Agent at `localhost:4316` because `localhost` inside a container refers to the container's network namespace, not the EC2 host.
322
+
323
+ **For Linux-based containers:**
324
+
325
+ Find the existing `docker run` command in UserData. Replace it with:
326
+
327
+ ```typescript
328
+ instance.userData.addCommands(
329
+ '# Run container with Application Signals environment variables',
330
+ `docker run -d --name {{APP_NAME}} \\`,
331
+ ` -p {{PORT}}:{{PORT}} \\`,
332
+ ` -e OTEL_DOTNET_AUTO_HOME=/opt/otel-dotnet-auto \\`,
333
+ ` -e DOTNET_STARTUP_HOOKS=/opt/otel-dotnet-auto/net/OpenTelemetry.AutoInstrumentation.StartupHook.dll \\`,
334
+ ` -e DOTNET_SHARED_STORE=/opt/otel-dotnet-auto/store \\`,
335
+ ` -e DOTNET_ADDITIONAL_DEPS=/opt/otel-dotnet-auto/AdditionalDeps \\`,
336
+ ` -e OTEL_METRICS_EXPORTER=none \\`,
337
+ ` -e OTEL_LOGS_EXPORTER=none \\`,
338
+ ` -e OTEL_AWS_APPLICATION_SIGNALS_ENABLED=true \\`,
339
+ ` -e OTEL_EXPORTER_OTLP_PROTOCOL=http/protobuf \\`,
340
+ ` -e OTEL_AWS_APPLICATION_SIGNALS_EXPORTER_ENDPOINT=http://localhost:4316/v1/metrics \\`,
341
+ ` -e OTEL_EXPORTER_OTLP_TRACES_ENDPOINT=http://localhost:4316/v1/traces \\`,
342
+ ` -e OTEL_RESOURCE_ATTRIBUTES=service.name={{SERVICE_NAME}} \\`,
343
+ ` --network host \\`,
344
+ ` {{IMAGE_URI}}`,
345
+ );
346
+ ```
347
+
348
+ #### Option B: Non-Docker Deployment
349
+
350
+ Find the existing command that starts the .NET application. Add the environment variables BEFORE it:
351
+
352
+ **For Linux instances:**
353
+
354
+ ```typescript
355
+ instance.userData.addCommands(
356
+ '# Set OpenTelemetry environment variables',
357
+ '. /opt/otel-dotnet-auto/instrument.sh',
358
+ 'export OTEL_METRICS_EXPORTER=none',
359
+ 'export OTEL_LOGS_EXPORTER=none',
360
+ 'export OTEL_AWS_APPLICATION_SIGNALS_ENABLED=true',
361
+ 'export OTEL_EXPORTER_OTLP_PROTOCOL=http/protobuf',
362
+ 'export OTEL_AWS_APPLICATION_SIGNALS_EXPORTER_ENDPOINT=http://localhost:4316/v1/metrics',
363
+ 'export OTEL_EXPORTER_OTLP_TRACES_ENDPOINT=http://localhost:4316/v1/traces',
364
+ 'export OTEL_RESOURCE_ATTRIBUTES=service.name={{SERVICE_NAME}}',
365
+ '',
366
+ '# Start application (existing command remains unchanged)',
367
+ '# Example: dotnet run --urls http://0.0.0.0:8080',
368
+ '# The OTEL environment variables will automatically enable instrumentation',
369
+ );
370
+ ```
371
+
372
+ **For Windows instances:**
373
+
374
+ ```typescript
375
+ instance.userData.addCommands(
376
+ '# Set OpenTelemetry environment variables at machine level',
377
+ '$env:INSTALL_DIR = "C:\\Program Files\\AWS Distro for OpenTelemetry AutoInstrumentation"',
378
+ '[Environment]::SetEnvironmentVariable("CORECLR_ENABLE_PROFILING", "1", "Machine")',
379
+ '[Environment]::SetEnvironmentVariable("CORECLR_PROFILER", "{918728DD-259F-4A6A-AC2B-B85E1B658318}", "Machine")',
380
+ '[Environment]::SetEnvironmentVariable("CORECLR_PROFILER_PATH_64", (Join-Path $env:INSTALL_DIR "win-x64/OpenTelemetry.AutoInstrumentation.Native.dll"), "Machine")',
381
+ '[Environment]::SetEnvironmentVariable("CORECLR_PROFILER_PATH_32", (Join-Path $env:INSTALL_DIR "win-x86/OpenTelemetry.AutoInstrumentation.Native.dll"), "Machine")',
382
+ '[Environment]::SetEnvironmentVariable("COR_ENABLE_PROFILING", "1", "Machine")',
383
+ '[Environment]::SetEnvironmentVariable("COR_PROFILER", "{918728DD-259F-4A6A-AC2B-B85E1B658318}", "Machine")',
384
+ '[Environment]::SetEnvironmentVariable("COR_PROFILER_PATH_64", (Join-Path $env:INSTALL_DIR "win-x64/OpenTelemetry.AutoInstrumentation.Native.dll"), "Machine")',
385
+ '[Environment]::SetEnvironmentVariable("COR_PROFILER_PATH_32", (Join-Path $env:INSTALL_DIR "win-x86/OpenTelemetry.AutoInstrumentation.Native.dll"), "Machine")',
386
+ '[Environment]::SetEnvironmentVariable("DOTNET_ADDITIONAL_DEPS", (Join-Path $env:INSTALL_DIR "AdditionalDeps"), "Machine")',
387
+ '[Environment]::SetEnvironmentVariable("DOTNET_SHARED_STORE", (Join-Path $env:INSTALL_DIR "store"), "Machine")',
388
+ '[Environment]::SetEnvironmentVariable("DOTNET_STARTUP_HOOKS", (Join-Path $env:INSTALL_DIR "net/OpenTelemetry.AutoInstrumentation.StartupHook.dll"), "Machine")',
389
+ '[Environment]::SetEnvironmentVariable("OTEL_DOTNET_AUTO_HOME", $env:INSTALL_DIR, "Machine")',
390
+ '[Environment]::SetEnvironmentVariable("OTEL_DOTNET_AUTO_PLUGINS", "AWS.Distro.OpenTelemetry.AutoInstrumentation.Plugin, AWS.Distro.OpenTelemetry.AutoInstrumentation", "Machine")',
391
+ '[Environment]::SetEnvironmentVariable("OTEL_RESOURCE_ATTRIBUTES", "service.name={{SERVICE_NAME}}", "Machine")',
392
+ '[Environment]::SetEnvironmentVariable("OTEL_EXPORTER_OTLP_PROTOCOL", "http/protobuf", "Machine")',
393
+ '[Environment]::SetEnvironmentVariable("OTEL_EXPORTER_OTLP_ENDPOINT", "http://127.0.0.1:4316", "Machine")',
394
+ '[Environment]::SetEnvironmentVariable("OTEL_AWS_APPLICATION_SIGNALS_EXPORTER_ENDPOINT", "http://127.0.0.1:4316/v1/metrics", "Machine")',
395
+ '[Environment]::SetEnvironmentVariable("OTEL_METRICS_EXPORTER", "none", "Machine")',
396
+ '[Environment]::SetEnvironmentVariable("OTEL_AWS_APPLICATION_SIGNALS_ENABLED", "true", "Machine")',
397
+ '[Environment]::SetEnvironmentVariable("OTEL_TRACES_SAMPLER", "xray", "Machine")',
398
+ '[Environment]::SetEnvironmentVariable("OTEL_TRACES_SAMPLER_ARG", "http://127.0.0.1:2000", "Machine")',
399
+ '# The command below is optional. It registers Application signals in IIS after starting the IIS/W3SVC service and starting the WebAppPool if they exist',
400
+ 'Register-OpenTelemetryForIIS',
401
+ );
402
+ ```
403
+
404
+ ## Completion
405
+
406
+ **Tell the user:**
407
+
408
+ "I've completed the Application Signals enablement for your .NET application. Here's what I modified:
409
+
410
+ **Files Changed:**
411
+ - IAM role: Added CloudWatchAgentServerPolicy
412
+ - UserData: Installed and configured CloudWatch Agent
413
+ - UserData: Downloaded and installed ADOT .NET auto-instrumentation
414
+ - UserData/Dockerfile: Added OpenTelemetry environment variables
415
+ - Dockerfile: Installed ADOT .NET auto-instrumentation (if using Docker)
416
+
417
+ **Next Steps:**
418
+ 1. Review the changes I made using `git diff`
419
+ 2. Deploy your infrastructure:
420
+ - For CDK: `cdk deploy`
421
+ - For Terraform: `terraform apply`
422
+ - For CloudFormation: Deploy your stack
423
+ 3. After deployment, wait 5-10 minutes for telemetry data to start flowing
424
+
425
+ **Verification:**
426
+ Once deployed, you can verify Application Signals is working by:
427
+ - Opening the AWS CloudWatch Console
428
+ - Navigating to Application Signals → Services
429
+ - Looking for your service (named: {{SERVICE_NAME}})
430
+ - Checking that traces and metrics are being collected
431
+
432
+ **Monitor Application Health:**
433
+ After enablement, you can monitor your application's operational health using Application Signals dashboards. For more information, see [Monitor the operational health of your applications with Application Signals](https://docs.aws.amazon.com/AmazonCloudWatch/latest/monitoring/Services.html).
434
+
435
+ Let me know if you'd like me to make any adjustments before you deploy!"