Skip to content

aws: add integrations for CloudWatch Explore related feature #10321

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 6 commits into
base: master
Choose a base branch
from
Open
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
cloudwatch: modify string construction method to be OS-agnostic
Signed-off-by: Zhihong Lin <[email protected]>
  • Loading branch information
zhihonl committed May 9, 2025
commit 95aca0be5017115193d358f16cbc014c92f76c85
20 changes: 17 additions & 3 deletions plugins/out_cloudwatch_logs/cloudwatch_api.c
Original file line number Diff line number Diff line change
Expand Up @@ -1022,17 +1022,31 @@ static char* find_fallback_environment(struct flb_cloudwatch *ctx, entity *entit
return NULL;
}
char *fallback_env = NULL;

int ret;
/*
* Possible fallback environments:
* 1. eks:cluster-name/namespace
* 2. k8s:cluster-name/namespace
*/
if (entity->attributes->platform_type != NULL && entity->attributes->cluster_name != NULL && entity->attributes->namespace != NULL) {
int ret = asprintf(&fallback_env, "%s:%s/%s", entity->attributes->platform_type, entity->attributes->cluster_name, entity->attributes->namespace);
if (ret == -1) {
/* Calculate required length */
/* Add 3 for ':' '/' and null terminator */
size_t len = strlen(entity->attributes->platform_type) +
strlen(entity->attributes->cluster_name) +
strlen(entity->attributes->namespace) + 3;

fallback_env = flb_malloc(len);
if (!fallback_env) {
return NULL;
}

/* Use snprintf for cross-platform compatibility */
ret = snprintf(fallback_env, len, "%s:%s/%s", entity->attributes->platform_type, entity->attributes->cluster_name, entity->attributes->namespace);
if (ret < 0 || ret >= len) {
flb_free(fallback_env);
return NULL;
}

return fallback_env;
}
return NULL;
Expand Down
Loading