@@ -187,18 +187,25 @@ static int dd_remap_ecs_task_arn(const char *tag_name,
187
187
char * remain ;
188
188
char * split ;
189
189
char * task_arn ;
190
+ char * task_id ;
190
191
int ret ;
191
192
192
193
buf = flb_sds_create_len (attr_value .via .str .ptr , attr_value .via .str .size );
193
194
if (!buf ) {
194
195
flb_errno ();
195
196
return -1 ;
196
197
}
197
-
198
198
/*
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 --
202
209
if ((strlen (buf ) > strlen (ECS_ARN_PREFIX )) &&
203
210
(strncmp (buf , ECS_ARN_PREFIX , strlen (ECS_ARN_PREFIX )) == 0 )) {
204
211
@@ -214,19 +221,17 @@ static int dd_remap_ecs_task_arn(const char *tag_name,
214
221
}
215
222
}
216
223
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 );
222
228
}
223
229
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 );
229
232
}
233
+ // --- End task_id logic ---
234
+
230
235
flb_sds_destroy (buf );
231
236
if (ret < 0 ) {
232
237
return -1 ;
0 commit comments