Skip to content

Modify agent logs to be less verbose by truncating certain values#4940

Merged
mye956 merged 1 commit into
aws:devfrom
mye956:modify-logs
Apr 27, 2026
Merged

Modify agent logs to be less verbose by truncating certain values#4940
mye956 merged 1 commit into
aws:devfrom
mye956:modify-logs

Conversation

@mye956
Copy link
Copy Markdown
Contributor

@mye956 mye956 commented Apr 23, 2026

Summary

This PR aims to truncate certain values that are logged within the ECS agent application. It also cleans up unnecessary log values that aren't helpful.

Implementation details

  • Added new utility function to truncate strings up to a specific length

Testing

Manual testing via a custom ECS Agent container image. Launched a simple nginx webapp task. ECS Agent logs:

level=info time=2026-04-23T21:50:47Z msg="Successfully got ECS instance credentials from provider: EC2RoleProvider"     
  level=info time=2026-04-23T21:50:48Z msg="Establishing a Websocket connection"                                          
  url="https://ecs-a-12.us-west-2.amazonaws.com/ws?agentHash=fbc95536&agentVersion=1.103.0&clusterArn=default&containerIns
  tanceArn=arn%3Aaws%3Aecs%3Aus-west-2%3A<ACCOUNT_ID>%3Acontainer-instance%2Fdefault%2F<CONTAINER_INSTANCE_ID>&dockerVersi
  on=DockerVersion%3A+25.0.14&protocolVersion=2&sendCredentials=true&seqNum=1"                                            
  level=info time=2026-04-23T21:50:48Z msg="Websocket connection established." ExpectedDisconnectTime="2026-04-23         
  22:20:48"                                                                                                               
  URL="https://ecs-a-12.us-west-2.amazonaws.com/ws?agentHash=fbc95536&agentVersion=1.103.0&clusterArn=default&containerIns
  tanceArn=arn%3Aaws%3Aecs%3Aus-west-2%3A<ACCOUNT_ID>%3Acontainer-instance%2Fdefault%2F<CONTAINER_INSTANCE_ID>&dockerVersi
  on=DockerVersion%3A+25.0.14&protocolVersion=2&sendCredentials=true&seqNum=1"                                            
  ConnectTime="2026-04-23 21:50:48" maxConnectionDuration=30m50.572348903s                                                
  level=info time=2026-04-23T21:51:23Z msg="Found application credentials for task" roleType="TaskApplication"            
  credentialsID="767f1b27-REDACTED" taskARN="arn:aws:ecs:us-west-2:<ACCOUNT_ID>:task/default/<TASK_ID>" taskVersion="1"   
  roleARN="arn:aws:iam::<ACCOUNT_ID>:role/ecsTaskExecutionRole"                                                           
  level=info time=2026-04-23T21:51:23Z msg="Found execution credentials for task"                                         
  taskARN="arn:aws:ecs:us-west-2:<ACCOUNT_ID>:task/default/<TASK_ID>" taskVersion="1"                                     
  roleARN="arn:aws:iam::<ACCOUNT_ID>:role/TaskExecutionRoleARN" roleType="TaskExecution" credentialsID="8f42fc44-REDACTED"
  level=info time=2026-04-23T21:51:23Z msg="Found application credentials for task"                                       
  taskARN="arn:aws:ecs:us-west-2:<ACCOUNT_ID>:task/default/<TASK_ID>" taskVersion="1"                                     
  roleARN="arn:aws:iam::<ACCOUNT_ID>:role/ecsTaskExecutionRole" roleType="TaskApplication"                                
  credentialsID="f7b3db46-REDACTED"                                                                                       
  level=info time=2026-04-23T21:51:23Z msg="Found execution credentials for task"                                         
  taskARN="arn:aws:ecs:us-west-2:<ACCOUNT_ID>:task/default/<TASK_ID>" taskVersion="1"                                     
  roleARN="arn:aws:iam::<ACCOUNT_ID>:role/TaskExecutionRoleARN" roleType="TaskExecution" credentialsID="b35d70f2-REDACTED"

New tests cover the changes: yes

Description for the changelog

enhancement: Truncate log values to make agent logs less verbose

Additional Information

Does this PR include breaking model changes? If so, Have you added transformation functions?

Does this PR include the addition of new environment variables in the README?

Licensing

By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.

@mye956 mye956 requested a review from a team as a code owner April 23, 2026 20:01
@mye956 mye956 changed the title WIP [WIP] Modify agent logs to be less verbose Apr 23, 2026
@mye956 mye956 changed the title [WIP] Modify agent logs to be less verbose [WIP] Modify agent logs to be less verbose by truncating certain values Apr 23, 2026
@mye956 mye956 changed the title [WIP] Modify agent logs to be less verbose by truncating certain values Modify agent logs to be less verbose by truncating certain values Apr 23, 2026
@sparrc
Copy link
Copy Markdown
Contributor

sparrc commented Apr 23, 2026

It also cleans up unnecessary log values that aren't helpful.

It doesnt do this does it?

Comment thread agent/acs/session/payload_responder.go
@mye956
Copy link
Copy Markdown
Contributor Author

mye956 commented Apr 23, 2026

It also cleans up unnecessary log values that aren't helpful.

It doesnt do this does it?

It does if you take a look at awslogsCredsEndpointOpt: credentialsEndpointRelativeURI, in agent/api/task/task.go

@mye956 mye956 merged commit 7d5769c into aws:dev Apr 27, 2026
43 of 44 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants