@@ -187,18 +187,25 @@ static int dd_remap_ecs_task_arn(const char *tag_name,
187187 char * remain ;
188188 char * split ;
189189 char * task_arn ;
190+ char * task_id ;
190191 int ret ;
191192
192193 buf = flb_sds_create_len (attr_value .via .str .ptr , attr_value .via .str .size );
193194 if (!buf ) {
194195 flb_errno ();
195196 return -1 ;
196197 }
197-
198198 /*
199- * if the input is invalid, not in the form of "arn:aws:ecs:region:XXXX"
200- * then we won't add the "region" in the dd_tags.
201- */
199+ * Use the full task ARN for compatibility with Datadog products
200+ * that expect the complete ARN format
201+ */
202+ ret = dd_remap_append_kv_to_ddtags (tag_name , buf , flb_sds_len (buf ), dd_tags_buf );
203+ if (ret < 0 ) {
204+ flb_sds_destroy (buf );
205+ return -1 ;
206+ }
207+
208+ // --- Begin task_id logic --
202209 if ((strlen (buf ) > strlen (ECS_ARN_PREFIX )) &&
203210 (strncmp (buf , ECS_ARN_PREFIX , strlen (ECS_ARN_PREFIX )) == 0 )) {
204211
@@ -214,19 +221,17 @@ static int dd_remap_ecs_task_arn(const char *tag_name,
214221 }
215222 }
216223
217- task_arn = strstr (buf , ECS_TASK_PREFIX );
218- if (task_arn != NULL ) {
219- /* parse out the task_arn */
220- task_arn += strlen (ECS_TASK_PREFIX );
221- ret = dd_remap_append_kv_to_ddtags (tag_name , task_arn , strlen (task_arn ), dd_tags_buf );
224+ task_id = strstr (buf , ECS_TASK_PREFIX );
225+ if (task_id != NULL ) {
226+ task_id += strlen (ECS_TASK_PREFIX );
227+ ret = dd_remap_append_kv_to_ddtags ("task_id" , task_id , strlen (task_id ), dd_tags_buf );
222228 }
223229 else {
224- /*
225- * if the input is invalid, not in the form of "XXXXXXXXtask/"task-arn
226- * then we preverse the original value under tag "task_arn".
227- */
228- ret = dd_remap_append_kv_to_ddtags (tag_name , buf , strlen (buf ), dd_tags_buf );
230+ // If invalid, preserve the original value under task_id
231+ ret = dd_remap_append_kv_to_ddtags ("task_id" , buf , strlen (buf ), dd_tags_buf );
229232 }
233+ // --- End task_id logic ---
234+
230235 flb_sds_destroy (buf );
231236 if (ret < 0 ) {
232237 return -1 ;
0 commit comments