Skip to content

Add daemonName field to ECSTask proto#456

Merged
gh-worker-dd-mergequeue-cf854d[bot] merged 1 commit into
masterfrom
stzou/EXP-309
May 1, 2026
Merged

Add daemonName field to ECSTask proto#456
gh-worker-dd-mergequeue-cf854d[bot] merged 1 commit into
masterfrom
stzou/EXP-309

Conversation

@stzou
Copy link
Copy Markdown
Contributor

@stzou stzou commented Mar 10, 2026

What does this PR do?

Adds new field daemonName to the ECSTask proto. This field indicates that the ECS task is part of an ECS daemon.

Motivation

With the release of Daemons on ECS Managed Instances, we now have a new daemon resource type. We need to identify that an ECS Task belongs to an ECS daemon as opposed to an ECS service.

Additional Notes

Possible Drawbacks / Trade-offs

Describe how to test/QA your changes

Reviewer's Checklist

Reviewers: please see the review guidelines.

@stzou stzou force-pushed the stzou/EXP-309 branch from 4fe30d3 to 674bde7 Compare May 1, 2026 15:32
@stzou stzou marked this pull request as ready for review May 1, 2026 15:33
@stzou stzou requested review from a team as code owners May 1, 2026 15:33
stzou added a commit to DataDog/datadog-agent that referenced this pull request May 1, 2026
Bump agent-payload to a pseudo-version that includes the new daemonName
proto field (DataDog/agent-payload#456) and propagate task.Task.DaemonName
through ExtractECSTask so the orchestrator emits the daemon identifier
to the backend.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
@gh-worker-dd-mergequeue-cf854d gh-worker-dd-mergequeue-cf854d Bot merged commit cc18bb5 into master May 1, 2026
9 checks passed
stzou added a commit to DataDog/datadog-agent that referenced this pull request May 1, 2026
DataDog/agent-payload#456 was merged and tagged as v5.0.195. Move off
the pseudo-version onto the released tag.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
stzou added a commit to DataDog/datadog-agent that referenced this pull request May 6, 2026
Bump agent-payload to a pseudo-version that includes the new daemonName
proto field (DataDog/agent-payload#456) and propagate task.Task.DaemonName
through ExtractECSTask so the orchestrator emits the daemon identifier
to the backend.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
stzou added a commit to DataDog/datadog-agent that referenced this pull request May 6, 2026
DataDog/agent-payload#456 was merged and tagged as v5.0.195. Move off
the pseudo-version onto the released tag.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
gh-worker-dd-mergequeue-cf854d Bot pushed a commit to DataDog/datadog-agent that referenced this pull request May 7, 2026
### What does this PR do?

Adds support for parsing the ECS `/tasks` host metadata endpoint on ECS Managed Instances, and wires daemon-task identification through workloadmeta and the orchestrator transformer so the backend can produce `ecs_daemon_name` / `daemon-task-definition` tags.

  **`pkg/util/ecs/metadata/v3or4`**                                                                                     
  - Add `Group` field to the `Task` struct. AWS uses `Group` (with the `service:` / `daemon:` / `family:` prefix
  convention) on the `/tasks` host endpoint to identify a task's scheduling owner. The per-task `/task` and             
  `/taskWithTags` endpoints do not return it.                       
  - Add `tasksMetadataPath = "/tasks"` constant and `GetTasks(ctx) ([]Task, error)` on the `Client` interface and       
  implementation.                                                                                                       
                                                                                  
  **`comp/core/workloadmeta`**                                                                                          
  - Add `DaemonName` and `DaemonARN` fields to the `ECSTask` entity (`def/types.go`, both `proto:"ignore"` like the
  other resolved-name fields).                                                                                          
  - Add `BuildDaemonARN()` helper in `collectors/util/ecs_util.go` and `parseDaemonNameFromGroup()` to derive the daemon
   name from a `daemon:`-prefixed `Group`.                                                                              
  - In `ParseV4Task`, populate `DaemonName` and `DaemonARN` for daemon-scheduled tasks.
                                                                                                                        
  **`comp/core/workloadmeta/collectors/internal/ecs`**                                                                  
  - Add `parseTasksFromV4TasksEndpoint`: fetches all host tasks via `metaV4.GetTasks()` in a single call.               
  - `setTaskCollectionParserForDaemon`: select the new parser when running on Managed Instances with a v4 client        
  available; fall back to the existing per-task parser on EC2.                                                          
  - `initializeDaemonMode`: opportunistically build a v4 client for the agent's own container (`V4FromCurrentTask`) so  
  the new parser is available.                                                                                          
                                                                                  
  **`comp/core/tagger`**                                                                                                
  - Add `EcsDaemonName` (`ecs_daemon`) and `EcsDaemonARN` (`daemon_arn`) tag constants in `tags/tags.go`.
  - Emit those tags from `collectors/workloadmeta_extract.go`, mirroring the existing `ecs_service` / `service_arn`     
  plumbing for service tasks.                                                                                           
                                                                                                                        
  **`pkg/collector/corechecks/cluster/orchestrator/transformers/ecs/task.go`**                                          
  - Wire `DaemonName: task.Task.DaemonName` into `ExtractECSTask` so the agent-payload `daemonName` proto field is
  populated.                                                                                                            
                                                                    
  **`go.mod`** (and sub-modules)                                                                                        
  - Bump `agent-payload` to `v5.0.195`, which includes the new `daemonName` field on the `ECSTask` proto
  ([DataDog/agent-payload#456](DataDog/agent-payload#456)).      
### Motivation

With ECS Managed Instances daemon scheduling, a single agent runs once per host and needs to enumerate every task on the instance. AWS shipped the new `/tasks` host endpoint for this, and exposes `Group` (rather than the originally proposed `DaemonName` field) as the daemon-task discriminator.

This is the agent-side prerequisite for correct `ecs_daemon_name` and `daemon-task-definition-arn` tagging in the backend.

### Describe how you validated your changes

  **Unit tests**                                                                                                        
  - `GetTasks` on the v3or4 client.                                 
  - `parseTasksFromV4TasksEndpoint` in the workloadmeta collector — daemon-name derivation from `Group` and stale-task  
  unset behavior.                                                                                                       
  - `setTaskCollectionParserForDaemon` — selection on Managed Instances vs. EC2.                                        
  - `BuildDaemonARN` and `parseDaemonNameFromGroup` (incl. the theoretical `"daemon:"` empty suffix).                   
  - `TestParseV4TaskDaemonGroup` / `TestParseV4TaskServiceGroup` — end-to-end population of DaemonName/DaemonARN vs.    
  ServiceName/ServiceARN on the `ECSTask` entity.                                                                       
  - `TestHandleECSTask` — new "ECS Managed Instances daemon task" case asserts `daemon_arn` and `ecs_daemon` tag        
  emission.                                                                                                             
  - `ExtractECSTask` continues to populate `DaemonName` on the proto.                                                                               


Deployed agent onto ECS MI using a daemon:
- confirmed that ECS tasks are reported and appear under ECS Explorer
<img width="1051" height="407" alt="image" src="https://github.com/user-attachments/assets/923ffed6-58e6-4ab1-892e-fb437d3e8249" />
 - we're also able to extract relevant daemon tags 
<img width="776" height="102" alt="image" src="https://github.com/user-attachments/assets/31ece2fd-a8ef-4f75-b5ce-e67a9ed65956" />
- daemon_arn and ecs_daemon present on metrics
<img width="852" height="147" alt="image" src="https://github.com/user-attachments/assets/542d9d11-e485-453f-ba98-6e3d7b6bd6f5" />


Co-authored-by: steve.zou <steve.zou@datadoghq.com>
chouetz pushed a commit to DataDog/datadog-agent that referenced this pull request May 13, 2026
### What does this PR do?

Adds support for parsing the ECS `/tasks` host metadata endpoint on ECS Managed Instances, and wires daemon-task identification through workloadmeta and the orchestrator transformer so the backend can produce `ecs_daemon_name` / `daemon-task-definition` tags.

  **`pkg/util/ecs/metadata/v3or4`**                                                                                     
  - Add `Group` field to the `Task` struct. AWS uses `Group` (with the `service:` / `daemon:` / `family:` prefix
  convention) on the `/tasks` host endpoint to identify a task's scheduling owner. The per-task `/task` and             
  `/taskWithTags` endpoints do not return it.                       
  - Add `tasksMetadataPath = "/tasks"` constant and `GetTasks(ctx) ([]Task, error)` on the `Client` interface and       
  implementation.                                                                                                       
                                                                                  
  **`comp/core/workloadmeta`**                                                                                          
  - Add `DaemonName` and `DaemonARN` fields to the `ECSTask` entity (`def/types.go`, both `proto:"ignore"` like the
  other resolved-name fields).                                                                                          
  - Add `BuildDaemonARN()` helper in `collectors/util/ecs_util.go` and `parseDaemonNameFromGroup()` to derive the daemon
   name from a `daemon:`-prefixed `Group`.                                                                              
  - In `ParseV4Task`, populate `DaemonName` and `DaemonARN` for daemon-scheduled tasks.
                                                                                                                        
  **`comp/core/workloadmeta/collectors/internal/ecs`**                                                                  
  - Add `parseTasksFromV4TasksEndpoint`: fetches all host tasks via `metaV4.GetTasks()` in a single call.               
  - `setTaskCollectionParserForDaemon`: select the new parser when running on Managed Instances with a v4 client        
  available; fall back to the existing per-task parser on EC2.                                                          
  - `initializeDaemonMode`: opportunistically build a v4 client for the agent's own container (`V4FromCurrentTask`) so  
  the new parser is available.                                                                                          
                                                                                  
  **`comp/core/tagger`**                                                                                                
  - Add `EcsDaemonName` (`ecs_daemon`) and `EcsDaemonARN` (`daemon_arn`) tag constants in `tags/tags.go`.
  - Emit those tags from `collectors/workloadmeta_extract.go`, mirroring the existing `ecs_service` / `service_arn`     
  plumbing for service tasks.                                                                                           
                                                                                                                        
  **`pkg/collector/corechecks/cluster/orchestrator/transformers/ecs/task.go`**                                          
  - Wire `DaemonName: task.Task.DaemonName` into `ExtractECSTask` so the agent-payload `daemonName` proto field is
  populated.                                                                                                            
                                                                    
  **`go.mod`** (and sub-modules)                                                                                        
  - Bump `agent-payload` to `v5.0.195`, which includes the new `daemonName` field on the `ECSTask` proto
  ([DataDog/agent-payload#456](DataDog/agent-payload#456)).      
### Motivation

With ECS Managed Instances daemon scheduling, a single agent runs once per host and needs to enumerate every task on the instance. AWS shipped the new `/tasks` host endpoint for this, and exposes `Group` (rather than the originally proposed `DaemonName` field) as the daemon-task discriminator.

This is the agent-side prerequisite for correct `ecs_daemon_name` and `daemon-task-definition-arn` tagging in the backend.

### Describe how you validated your changes

  **Unit tests**                                                                                                        
  - `GetTasks` on the v3or4 client.                                 
  - `parseTasksFromV4TasksEndpoint` in the workloadmeta collector — daemon-name derivation from `Group` and stale-task  
  unset behavior.                                                                                                       
  - `setTaskCollectionParserForDaemon` — selection on Managed Instances vs. EC2.                                        
  - `BuildDaemonARN` and `parseDaemonNameFromGroup` (incl. the theoretical `"daemon:"` empty suffix).                   
  - `TestParseV4TaskDaemonGroup` / `TestParseV4TaskServiceGroup` — end-to-end population of DaemonName/DaemonARN vs.    
  ServiceName/ServiceARN on the `ECSTask` entity.                                                                       
  - `TestHandleECSTask` — new "ECS Managed Instances daemon task" case asserts `daemon_arn` and `ecs_daemon` tag        
  emission.                                                                                                             
  - `ExtractECSTask` continues to populate `DaemonName` on the proto.                                                                               


Deployed agent onto ECS MI using a daemon:
- confirmed that ECS tasks are reported and appear under ECS Explorer
<img width="1051" height="407" alt="image" src="https://github.com/user-attachments/assets/923ffed6-58e6-4ab1-892e-fb437d3e8249" />
 - we're also able to extract relevant daemon tags 
<img width="776" height="102" alt="image" src="https://github.com/user-attachments/assets/31ece2fd-a8ef-4f75-b5ce-e67a9ed65956" />
- daemon_arn and ecs_daemon present on metrics
<img width="852" height="147" alt="image" src="https://github.com/user-attachments/assets/542d9d11-e485-453f-ba98-6e3d7b6bd6f5" />


Co-authored-by: steve.zou <steve.zou@datadoghq.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants