diff --git a/plugins/filter_aws/aws.c b/plugins/filter_aws/aws.c index 4ac611aabd7..89ac94dacd8 100644 --- a/plugins/filter_aws/aws.c +++ b/plugins/filter_aws/aws.c @@ -558,7 +558,7 @@ static int cb_aws_filter(const void *data, size_t bytes, ctx->availability_zone_len); } - if (ctx->instance_id_include) { + if (ctx->instance_id_include && !ctx->enable_entity) { msgpack_pack_str(&tmp_pck, FLB_FILTER_AWS_INSTANCE_ID_KEY_LEN); msgpack_pack_str_body(&tmp_pck, FLB_FILTER_AWS_INSTANCE_ID_KEY, @@ -566,6 +566,14 @@ static int cb_aws_filter(const void *data, size_t bytes, msgpack_pack_str(&tmp_pck, ctx->instance_id_len); msgpack_pack_str_body(&tmp_pck, ctx->instance_id, ctx->instance_id_len); + } else if (ctx->instance_id_include && ctx->enable_entity) { + msgpack_pack_str(&tmp_pck, FLB_FILTER_AWS_ENTITY_INSTANCE_ID_KEY_LEN); + msgpack_pack_str_body(&tmp_pck, + FLB_FILTER_AWS_ENTITY_INSTANCE_ID_KEY, + FLB_FILTER_AWS_ENTITY_INSTANCE_ID_KEY_LEN); + msgpack_pack_str(&tmp_pck, ctx->instance_id_len); + msgpack_pack_str_body(&tmp_pck, + ctx->instance_id, ctx->instance_id_len); } if (ctx->instance_type_include) { @@ -740,6 +748,11 @@ static struct flb_config_map config_map[] = { 0, FLB_TRUE, offsetof(struct flb_filter_aws, hostname_include), "Enable EC2 instance hostname" }, + { + FLB_CONFIG_MAP_BOOL, "enable_entity", "false", + 0, FLB_TRUE, offsetof(struct flb_filter_aws, enable_entity), + "Enable entity prefix for necessary fields" + }, {0} }; diff --git a/plugins/filter_aws/aws.h b/plugins/filter_aws/aws.h index 21d3e75fefc..65d8a19c9ac 100644 --- a/plugins/filter_aws/aws.h +++ b/plugins/filter_aws/aws.h @@ -51,6 +51,8 @@ #define FLB_FILTER_AWS_AVAILABILITY_ZONE_KEY_LEN 2 #define FLB_FILTER_AWS_INSTANCE_ID_KEY "ec2_instance_id" #define FLB_FILTER_AWS_INSTANCE_ID_KEY_LEN 15 +#define FLB_FILTER_AWS_ENTITY_INSTANCE_ID_KEY "aws_entity_ec2_instance_id" +#define FLB_FILTER_AWS_ENTITY_INSTANCE_ID_KEY_LEN 26 #define FLB_FILTER_AWS_INSTANCE_TYPE_KEY "ec2_instance_type" #define FLB_FILTER_AWS_INSTANCE_TYPE_KEY_LEN 17 #define FLB_FILTER_AWS_PRIVATE_IP_KEY "private_ip" @@ -111,6 +113,12 @@ struct flb_filter_aws { size_t hostname_len; int hostname_include; + /* + * Enable entity prefix appending. This appends + * 'aws_entity' to relevant keys + */ + int enable_entity; + /* number of new keys added by this plugin */ int new_keys; diff --git a/plugins/filter_kubernetes/kube_meta.c b/plugins/filter_kubernetes/kube_meta.c index 077324835cc..94cfc711be8 100644 --- a/plugins/filter_kubernetes/kube_meta.c +++ b/plugins/filter_kubernetes/kube_meta.c @@ -1028,27 +1028,6 @@ static int search_item_in_items(struct flb_kube_meta *meta, return ret; } -static char* find_fallback_environment(struct flb_kube *ctx, struct flb_kube_meta *meta) { - char *fallback_env = NULL; - - /* - * Possible fallback environments: - * 1. eks:cluster-name/namespace - * 2. k8s:cluster-name/namespace - */ - if(ctx->platform == NULL && ctx->set_platform != NULL) { - ctx->platform = flb_strdup(ctx->set_platform); - } - if (ctx->platform != NULL && meta->cluster != NULL && meta->namespace != NULL) { - int ret = asprintf(&fallback_env, "%s:%s/%s", ctx->platform, meta->cluster, meta->namespace); - if (ret == -1) { - return NULL; - } - return fallback_env; - } - return NULL; -} - static int merge_meta_from_tag(struct flb_kube *ctx, struct flb_kube_meta *meta, char **out_buf, size_t *out_size) { @@ -1260,25 +1239,13 @@ static int merge_meta(struct flb_kube_meta *meta, struct flb_kube *ctx, } } } - int fallback_environment_len = 0; - char *fallback_environment = NULL; if(ctx->use_pod_association) { - fallback_environment = find_fallback_environment(ctx,meta); - if(fallback_environment) { - fallback_environment_len = strlen(fallback_environment); - } pod_service_found = flb_hash_get(ctx->pod_hash_table, meta->podname, meta->podname_len, &tmp_service_attributes, &tmp_service_attr_size); if (pod_service_found != -1 && tmp_service_attributes != NULL) { map_size += tmp_service_attributes->fields; } - if(pod_service_found != -1 && tmp_service_attributes != NULL && tmp_service_attributes->environment[0] == '\0' && fallback_environment) { - map_size++; - } - if(pod_service_found == -1 && meta->workload != NULL && fallback_environment) { - map_size++; - } if(ctx->platform) { map_size++; } @@ -1304,51 +1271,41 @@ static int merge_meta(struct flb_kube_meta *meta, struct flb_kube *ctx, if(ctx->use_pod_association) { if (pod_service_found != -1 && tmp_service_attributes != NULL) { if (tmp_service_attributes->name[0] != '\0') { - msgpack_pack_str(&mp_pck, 12); - msgpack_pack_str_body(&mp_pck, "service_name", 12); + msgpack_pack_str(&mp_pck, 23); + msgpack_pack_str_body(&mp_pck, "aws_entity_service_name", 23); msgpack_pack_str(&mp_pck, tmp_service_attributes->name_len); msgpack_pack_str_body(&mp_pck, tmp_service_attributes->name, tmp_service_attributes->name_len); } if (tmp_service_attributes->environment[0] != '\0') { - msgpack_pack_str(&mp_pck, 11); - msgpack_pack_str_body(&mp_pck, "environment", 11); + msgpack_pack_str(&mp_pck, 22); + msgpack_pack_str_body(&mp_pck, "aws_entity_environment", 22); msgpack_pack_str(&mp_pck, tmp_service_attributes->environment_len); msgpack_pack_str_body(&mp_pck, tmp_service_attributes->environment, tmp_service_attributes->environment_len); - } else if(tmp_service_attributes->environment[0] == '\0' && fallback_environment) { - msgpack_pack_str(&mp_pck, 11); - msgpack_pack_str_body(&mp_pck, "environment", 11); - msgpack_pack_str(&mp_pck, fallback_environment_len); - msgpack_pack_str_body(&mp_pck, fallback_environment, fallback_environment_len); } if (tmp_service_attributes->name_source[0] != '\0') { - msgpack_pack_str(&mp_pck, 11); - msgpack_pack_str_body(&mp_pck, "name_source", 11); + msgpack_pack_str(&mp_pck, 22); + msgpack_pack_str_body(&mp_pck, "aws_entity_name_source", 22); msgpack_pack_str(&mp_pck, tmp_service_attributes->name_source_len); msgpack_pack_str_body(&mp_pck, tmp_service_attributes->name_source, tmp_service_attributes->name_source_len); } - } else if ( pod_service_found == -1 && meta->workload != NULL && fallback_environment) { - msgpack_pack_str(&mp_pck, 11); - msgpack_pack_str_body(&mp_pck, "environment", 11); - msgpack_pack_str(&mp_pck, fallback_environment_len); - msgpack_pack_str_body(&mp_pck, fallback_environment, fallback_environment_len); } if(ctx->platform != NULL) { int platform_len = strlen(ctx->platform); - msgpack_pack_str(&mp_pck, 8); - msgpack_pack_str_body(&mp_pck, "platform", 8); + msgpack_pack_str(&mp_pck, 19); + msgpack_pack_str_body(&mp_pck, "aws_entity_platform", 19); msgpack_pack_str(&mp_pck, platform_len); msgpack_pack_str_body(&mp_pck, ctx->platform, platform_len); } if (meta->cluster != NULL) { - msgpack_pack_str(&mp_pck, 7); - msgpack_pack_str_body(&mp_pck, "cluster", 7); + msgpack_pack_str(&mp_pck, 18); + msgpack_pack_str_body(&mp_pck, "aws_entity_cluster", 18); msgpack_pack_str(&mp_pck, meta->cluster_len); msgpack_pack_str_body(&mp_pck, meta->cluster, meta->cluster_len); } if (meta->workload != NULL) { - msgpack_pack_str(&mp_pck, 8); - msgpack_pack_str_body(&mp_pck, "workload", 8); + msgpack_pack_str(&mp_pck, 19); + msgpack_pack_str_body(&mp_pck, "aws_entity_workload", 19); msgpack_pack_str(&mp_pck, meta->workload_len); msgpack_pack_str_body(&mp_pck, meta->workload, meta->workload_len); } @@ -1460,10 +1417,6 @@ static int merge_meta(struct flb_kube_meta *meta, struct flb_kube *ctx, *out_buf = mp_sbuf.data; *out_size = mp_sbuf.size; - if(fallback_environment) { - flb_free(fallback_environment); - } - return 0; } diff --git a/plugins/out_cloudwatch_logs/cloudwatch_api.c b/plugins/out_cloudwatch_logs/cloudwatch_api.c index 8408f7bb348..fcc484bf982 100644 --- a/plugins/out_cloudwatch_logs/cloudwatch_api.c +++ b/plugins/out_cloudwatch_logs/cloudwatch_api.c @@ -523,6 +523,59 @@ static int truncate_log(const struct flb_cloudwatch *ctx, const char *log_buffer return FLB_FALSE; } +// Helper function to remove keys from a nested map +void remove_key_from_nested_map(msgpack_object_map *nested_map, msgpack_packer *pk, int filtered_fields) { + const int remaining_kv_pairs = nested_map->size - filtered_fields; + + // Pack the updated nested map into the packer, skipping keys in the remove list + msgpack_pack_map(pk, remaining_kv_pairs); // Initial size will adjust in the next loop + + for (uint32_t j = 0; j < nested_map->size; j++) { + msgpack_object_kv nested_kv = nested_map->ptr[j]; + + // Check if the current key is in the removal list + if (nested_kv.key.type == MSGPACK_OBJECT_STR && nested_kv.key.via.str.size > AWS_ENTITY_PREFIX_LEN && strncmp(nested_kv.key.via.str.ptr, AWS_ENTITY_PREFIX, AWS_ENTITY_PREFIX_LEN) == 0) { + // Skip the key in the remove list + continue; + } + + // Pack the remaining key-value pairs into the packer + msgpack_pack_object(pk, nested_kv.key); + msgpack_pack_object(pk, nested_kv.val); + } +} + +// Main function to remove a key from a nested map inside the root map +void remove_unneeded_field(msgpack_object *root_map, const char *nested_map_key, msgpack_packer *pk,int root_filtered_fields, int filtered_fields) { + if (root_map->type == MSGPACK_OBJECT_MAP) { + msgpack_object_map root = root_map->via.map; + + // Prepare to pack the modified root map (size may be unchanged or reduced) + msgpack_pack_map(pk, root.size-root_filtered_fields); // Assume no top-level key is removed + + for (uint32_t i = 0; i < root.size; i++) { + msgpack_object_kv root_kv = root.ptr[i]; + + // Check if this key matches the nested map key (e.g., "kubernetes") + if (root_kv.key.type == MSGPACK_OBJECT_STR && + strncmp(root_kv.key.via.str.ptr, nested_map_key, root_kv.key.via.str.size) == 0 && + root_kv.val.type == MSGPACK_OBJECT_MAP) { + + // Pack the nested map key + msgpack_pack_object(pk, root_kv.key); + + // Remove the unneeded key from the nested map + remove_key_from_nested_map(&root_kv.val.via.map, pk,filtered_fields); + } else if (root_kv.key.type == MSGPACK_OBJECT_STR && root_kv.key.via.str.size > AWS_ENTITY_PREFIX_LEN && strncmp(root_kv.key.via.str.ptr, AWS_ENTITY_PREFIX, AWS_ENTITY_PREFIX_LEN) == 0) { + } else { + // Pack other key-value pairs unchanged + msgpack_pack_object(pk, root_kv.key); + msgpack_pack_object(pk, root_kv.val); + } + } + } +} + /* * Processes the msgpack object @@ -545,9 +598,35 @@ int process_event(struct flb_cloudwatch *ctx, struct cw_flush *buf, char *tmp_buf_ptr; tmp_buf_ptr = buf->tmp_buf + buf->tmp_buf_offset; - ret = flb_msgpack_to_json(tmp_buf_ptr, - buf->tmp_buf_size - buf->tmp_buf_offset, - obj); + + if (ctx->add_entity && buf->current_stream->entity && buf->current_stream->entity->filter_count > 0) { + // Prepare a buffer to pack the modified map + msgpack_sbuffer sbuf; + msgpack_sbuffer_init(&sbuf); + msgpack_packer pk; + msgpack_packer_init(&pk, &sbuf, msgpack_sbuffer_write); + remove_unneeded_field(obj, "kubernetes",&pk,buf->current_stream->entity->root_filter_count, buf->current_stream->entity->filter_count); + + // Now, unpack the modified data into a new msgpack_object + msgpack_unpacked modified_unpacked; + msgpack_unpacked_init(&modified_unpacked); + msgpack_object modified_obj; + size_t modified_offset = 0; + if (msgpack_unpack_next(&modified_unpacked, sbuf.data, sbuf.size, &modified_offset)) { + modified_obj = modified_unpacked.data; + } + + ret = flb_msgpack_to_json(tmp_buf_ptr, + buf->tmp_buf_size - buf->tmp_buf_offset, + &modified_obj); + + msgpack_sbuffer_destroy(&sbuf); + msgpack_unpacked_destroy(&modified_unpacked); + } else { + ret = flb_msgpack_to_json(tmp_buf_ptr, + buf->tmp_buf_size - buf->tmp_buf_offset, + obj); + } if (ret <= 0) { /* * failure to write to buffer, @@ -943,6 +1022,27 @@ int pack_emf_payload(struct flb_cloudwatch *ctx, return 0; } +static char* find_fallback_environment(struct flb_cloudwatch *ctx, entity *entity) { + if(!ctx->add_entity || entity == NULL) { + return NULL; + } + char *fallback_env = NULL; + + /* + * 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) { + return NULL; + } + return fallback_env; + } + return NULL; +} + void parse_entity(struct flb_cloudwatch *ctx, entity *entity, msgpack_object map, int map_size) { int i,j; msgpack_object key, kube_key; @@ -958,13 +1058,17 @@ void parse_entity(struct flb_cloudwatch *ctx, entity *entity, msgpack_object map for (j=0; j < val_map_size; j++) { kube_key = val.via.map.ptr[j].key; kube_val = val.via.map.ptr[j].val; - if(strncmp(kube_key.via.str.ptr, "service_name", kube_key.via.str.size) == 0) { - if(entity->key_attributes->name != NULL) { + if(strncmp(kube_key.via.str.ptr, "aws_entity_service_name", kube_key.via.str.size) == 0) { + if(entity->key_attributes->name == NULL) { + entity->filter_count++; + } else { flb_free(entity->key_attributes->name); } entity->key_attributes->name = flb_strndup(kube_val.via.str.ptr, kube_val.via.str.size); - } else if(strncmp(kube_key.via.str.ptr, "environment", kube_key.via.str.size) == 0) { - if(entity->key_attributes->environment != NULL) { + } else if(strncmp(kube_key.via.str.ptr, "aws_entity_environment", kube_key.via.str.size) == 0) { + if(entity->key_attributes->environment == NULL) { + entity->filter_count++; + } else { flb_free(entity->key_attributes->environment); } entity->key_attributes->environment = flb_strndup(kube_val.via.str.ptr, kube_val.via.str.size); @@ -978,23 +1082,31 @@ void parse_entity(struct flb_cloudwatch *ctx, entity *entity, msgpack_object map flb_free(entity->attributes->node); } entity->attributes->node = flb_strndup(kube_val.via.str.ptr, kube_val.via.str.size); - } else if(strncmp(kube_key.via.str.ptr, "cluster", kube_key.via.str.size) == 0) { - if(entity->attributes->cluster_name != NULL) { + } else if(strncmp(kube_key.via.str.ptr, "aws_entity_cluster", kube_key.via.str.size) == 0) { + if(entity->attributes->cluster_name == NULL) { + entity->filter_count++; + } else { flb_free(entity->attributes->cluster_name); } entity->attributes->cluster_name = flb_strndup(kube_val.via.str.ptr, kube_val.via.str.size); - } else if(strncmp(kube_key.via.str.ptr, "workload", kube_key.via.str.size) == 0) { - if(entity->attributes->workload != NULL) { + } else if(strncmp(kube_key.via.str.ptr, "aws_entity_workload", kube_key.via.str.size) == 0) { + if(entity->attributes->workload == NULL) { + entity->filter_count++; + } else { flb_free(entity->attributes->workload); } entity->attributes->workload = flb_strndup(kube_val.via.str.ptr, kube_val.via.str.size); - } else if(strncmp(kube_key.via.str.ptr, "name_source", kube_key.via.str.size) == 0) { - if(entity->attributes->name_source != NULL) { + } else if(strncmp(kube_key.via.str.ptr, "aws_entity_name_source", kube_key.via.str.size) == 0) { + if(entity->attributes->name_source == NULL) { + entity->filter_count++; + } else { flb_free(entity->attributes->name_source); } entity->attributes->name_source = flb_strndup(kube_val.via.str.ptr, kube_val.via.str.size); - } else if(strncmp(kube_key.via.str.ptr, "platform", kube_key.via.str.size) == 0) { - if(entity->attributes->platform_type != NULL) { + } else if(strncmp(kube_key.via.str.ptr, "aws_entity_platform", kube_key.via.str.size) == 0) { + if(entity->attributes->platform_type == NULL) { + entity->filter_count++; + } else { flb_free(entity->attributes->platform_type); } entity->attributes->platform_type = flb_strndup(kube_val.via.str.ptr, kube_val.via.str.size); @@ -1002,8 +1114,10 @@ void parse_entity(struct flb_cloudwatch *ctx, entity *entity, msgpack_object map } } } - if(strncmp(key.via.str.ptr, "ec2_instance_id",key.via.str.size ) == 0 ) { - if(entity->attributes->instance_id != NULL) { + if(strncmp(key.via.str.ptr, "aws_entity_ec2_instance_id",key.via.str.size ) == 0 ) { + if(entity->attributes->instance_id == NULL) { + entity->root_filter_count++; + } else { flb_free(entity->attributes->instance_id); } entity->attributes->instance_id = flb_strndup(val.via.str.ptr, val.via.str.size); @@ -1013,6 +1127,9 @@ void parse_entity(struct flb_cloudwatch *ctx, entity *entity, msgpack_object map entity->key_attributes->name = flb_strndup(entity->attributes->workload, strlen(entity->attributes->workload)); entity->attributes->name_source = flb_strndup("K8sWorkload", 11); } + if(entity->key_attributes->environment == NULL) { + entity->key_attributes->environment = find_fallback_environment(ctx, entity); + } } void update_or_create_entity(struct flb_cloudwatch *ctx, struct log_stream *stream, const msgpack_object map) { @@ -1034,6 +1151,8 @@ void update_or_create_entity(struct flb_cloudwatch *ctx, struct log_stream *stre return; } memset(stream->entity->attributes, 0, sizeof(entity_attributes)); + stream->entity->filter_count = 0; + stream->entity->root_filter_count = 0; parse_entity(ctx,stream->entity,map, map.via.map.size); } else { diff --git a/plugins/out_cloudwatch_logs/cloudwatch_api.h b/plugins/out_cloudwatch_logs/cloudwatch_api.h index 064cbe94844..b8be9d2d39b 100644 --- a/plugins/out_cloudwatch_logs/cloudwatch_api.h +++ b/plugins/out_cloudwatch_logs/cloudwatch_api.h @@ -44,6 +44,10 @@ /* 256KiB minus 26 bytes for the event */ #define MAX_EVENT_LEN 262118 +/* Prefix used for entity fields only */ +#define AWS_ENTITY_PREFIX "aws_entity" +#define AWS_ENTITY_PREFIX_LEN 10 + #include "cloudwatch_logs.h" void cw_flush_destroy(struct cw_flush *buf); diff --git a/plugins/out_cloudwatch_logs/cloudwatch_logs.h b/plugins/out_cloudwatch_logs/cloudwatch_logs.h index afd0b888b9c..21816176fe2 100644 --- a/plugins/out_cloudwatch_logs/cloudwatch_logs.h +++ b/plugins/out_cloudwatch_logs/cloudwatch_logs.h @@ -35,6 +35,8 @@ typedef struct entity { struct entity_key_attributes *key_attributes; struct entity_attributes *attributes; + int filter_count; + int root_filter_count; }entity; /* KeyAttributes used for CloudWatch Entity object diff --git a/tests/runtime/data/kubernetes/out/options/options_use-kubelet-disabled-daemonset_fluent-bit.out b/tests/runtime/data/kubernetes/out/options/options_use-kubelet-disabled-daemonset_fluent-bit.out index dbfcdb92d3c..39d46da6ab0 100644 --- a/tests/runtime/data/kubernetes/out/options/options_use-kubelet-disabled-daemonset_fluent-bit.out +++ b/tests/runtime/data/kubernetes/out/options/options_use-kubelet-disabled-daemonset_fluent-bit.out @@ -1 +1 @@ -[1554141513.598656,{"log":"Fluent Bit is logging\n","stream":"stdout","kubernetes":{"pod_name":"use-kubelet-disabled-daemonset","namespace_name":"options","workload":"my-daemonset","pod_id":"e9f2963f-55f2-11e9-84c5-02e422b8a84a","labels":{"app.kubernetes.io/name":"fluent-bit"},"annotations":{"prometheus.io/path":"/api/v1/metrics/prometheus","prometheus.io/port":"2020","prometheus.io/scrape":"true"},"host":"ip-10-49-18-80.eu-west-1.compute.internal","container_name":"fluent-bit","docker_id":"c9898099f6d235126d564ed38a020007ea7a6fac6e25e718de683c9dd0076c16","container_hash":"fluent/fluent-bit@sha256:7ac0fd3569af866e9a6a22eb592744200d2dbe098cf066162453f8d0b06c531f","container_image":"fluent/fluent-bit:latest"}}] +[1554141513.598656,{"log":"Fluent Bit is logging\n","stream":"stdout","kubernetes":{"pod_name":"use-kubelet-disabled-daemonset","namespace_name":"options","aws_entity_workload":"my-daemonset","pod_id":"e9f2963f-55f2-11e9-84c5-02e422b8a84a","labels":{"app.kubernetes.io/name":"fluent-bit"},"annotations":{"prometheus.io/path":"/api/v1/metrics/prometheus","prometheus.io/port":"2020","prometheus.io/scrape":"true"},"host":"ip-10-49-18-80.eu-west-1.compute.internal","container_name":"fluent-bit","docker_id":"c9898099f6d235126d564ed38a020007ea7a6fac6e25e718de683c9dd0076c16","container_hash":"fluent/fluent-bit@sha256:7ac0fd3569af866e9a6a22eb592744200d2dbe098cf066162453f8d0b06c531f","container_image":"fluent/fluent-bit:latest"}}] diff --git a/tests/runtime/data/kubernetes/out/options/options_use-kubelet-disabled-deployment_fluent-bit.out b/tests/runtime/data/kubernetes/out/options/options_use-kubelet-disabled-deployment_fluent-bit.out index 10ac27f0592..8a05c321e4f 100644 --- a/tests/runtime/data/kubernetes/out/options/options_use-kubelet-disabled-deployment_fluent-bit.out +++ b/tests/runtime/data/kubernetes/out/options/options_use-kubelet-disabled-deployment_fluent-bit.out @@ -1 +1 @@ -[1554141513.598656,{"log":"Fluent Bit is logging\n","stream":"stdout","kubernetes":{"pod_name":"use-kubelet-disabled-deployment","namespace_name":"options","workload":"my-deployment","pod_id":"e9f2963f-55f2-11e9-84c5-02e422b8a84a","labels":{"app.kubernetes.io/name":"fluent-bit"},"annotations":{"prometheus.io/path":"/api/v1/metrics/prometheus","prometheus.io/port":"2020","prometheus.io/scrape":"true"},"host":"ip-10-49-18-80.eu-west-1.compute.internal","container_name":"fluent-bit","docker_id":"c9898099f6d235126d564ed38a020007ea7a6fac6e25e718de683c9dd0076c16","container_hash":"fluent/fluent-bit@sha256:7ac0fd3569af866e9a6a22eb592744200d2dbe098cf066162453f8d0b06c531f","container_image":"fluent/fluent-bit:latest"}}] +[1554141513.598656,{"log":"Fluent Bit is logging\n","stream":"stdout","kubernetes":{"pod_name":"use-kubelet-disabled-deployment","namespace_name":"options","aws_entity_workload":"my-deployment","pod_id":"e9f2963f-55f2-11e9-84c5-02e422b8a84a","labels":{"app.kubernetes.io/name":"fluent-bit"},"annotations":{"prometheus.io/path":"/api/v1/metrics/prometheus","prometheus.io/port":"2020","prometheus.io/scrape":"true"},"host":"ip-10-49-18-80.eu-west-1.compute.internal","container_name":"fluent-bit","docker_id":"c9898099f6d235126d564ed38a020007ea7a6fac6e25e718de683c9dd0076c16","container_hash":"fluent/fluent-bit@sha256:7ac0fd3569af866e9a6a22eb592744200d2dbe098cf066162453f8d0b06c531f","container_image":"fluent/fluent-bit:latest"}}] diff --git a/tests/runtime/data/kubernetes/out/options/options_use-kubelet-disabled-pod_fluent-bit.out b/tests/runtime/data/kubernetes/out/options/options_use-kubelet-disabled-pod_fluent-bit.out index 8aea6e523eb..855102b5940 100644 --- a/tests/runtime/data/kubernetes/out/options/options_use-kubelet-disabled-pod_fluent-bit.out +++ b/tests/runtime/data/kubernetes/out/options/options_use-kubelet-disabled-pod_fluent-bit.out @@ -1 +1 @@ -[1554141513.598656,{"log":"Fluent Bit is logging\n","stream":"stdout","kubernetes":{"pod_name":"use-kubelet-disabled-pod","namespace_name":"options","workload":"use-kubelet-disabled-pod","pod_id":"e9f2963f-55f2-11e9-84c5-02e422b8a84a","labels":{"app.kubernetes.io/name":"fluent-bit"},"annotations":{"prometheus.io/path":"/api/v1/metrics/prometheus","prometheus.io/port":"2020","prometheus.io/scrape":"true"},"host":"ip-10-49-18-80.eu-west-1.compute.internal","container_name":"fluent-bit","docker_id":"c9898099f6d235126d564ed38a020007ea7a6fac6e25e718de683c9dd0076c16","container_hash":"fluent/fluent-bit@sha256:7ac0fd3569af866e9a6a22eb592744200d2dbe098cf066162453f8d0b06c531f","container_image":"fluent/fluent-bit:latest"}}] +[1554141513.598656,{"log":"Fluent Bit is logging\n","stream":"stdout","kubernetes":{"pod_name":"use-kubelet-disabled-pod","namespace_name":"options","aws_entity_workload":"use-kubelet-disabled-pod","pod_id":"e9f2963f-55f2-11e9-84c5-02e422b8a84a","labels":{"app.kubernetes.io/name":"fluent-bit"},"annotations":{"prometheus.io/path":"/api/v1/metrics/prometheus","prometheus.io/port":"2020","prometheus.io/scrape":"true"},"host":"ip-10-49-18-80.eu-west-1.compute.internal","container_name":"fluent-bit","docker_id":"c9898099f6d235126d564ed38a020007ea7a6fac6e25e718de683c9dd0076c16","container_hash":"fluent/fluent-bit@sha256:7ac0fd3569af866e9a6a22eb592744200d2dbe098cf066162453f8d0b06c531f","container_image":"fluent/fluent-bit:latest"}}] diff --git a/tests/runtime/data/kubernetes/out/options/options_use-kubelet-disabled-replicaset_fluent-bit.out b/tests/runtime/data/kubernetes/out/options/options_use-kubelet-disabled-replicaset_fluent-bit.out index af2b3740f7f..a1804be5e87 100644 --- a/tests/runtime/data/kubernetes/out/options/options_use-kubelet-disabled-replicaset_fluent-bit.out +++ b/tests/runtime/data/kubernetes/out/options/options_use-kubelet-disabled-replicaset_fluent-bit.out @@ -1 +1 @@ -[1554141513.598656,{"log":"Fluent Bit is logging\n","stream":"stdout","kubernetes":{"pod_name":"use-kubelet-disabled-replicaset","namespace_name":"options","workload":"my-replicaset","pod_id":"e9f2963f-55f2-11e9-84c5-02e422b8a84a","labels":{"app.kubernetes.io/name":"fluent-bit"},"annotations":{"prometheus.io/path":"/api/v1/metrics/prometheus","prometheus.io/port":"2020","prometheus.io/scrape":"true"},"host":"ip-10-49-18-80.eu-west-1.compute.internal","container_name":"fluent-bit","docker_id":"c9898099f6d235126d564ed38a020007ea7a6fac6e25e718de683c9dd0076c16","container_hash":"fluent/fluent-bit@sha256:7ac0fd3569af866e9a6a22eb592744200d2dbe098cf066162453f8d0b06c531f","container_image":"fluent/fluent-bit:latest"}}] +[1554141513.598656,{"log":"Fluent Bit is logging\n","stream":"stdout","kubernetes":{"pod_name":"use-kubelet-disabled-replicaset","namespace_name":"options","aws_entity_workload":"my-replicaset","pod_id":"e9f2963f-55f2-11e9-84c5-02e422b8a84a","labels":{"app.kubernetes.io/name":"fluent-bit"},"annotations":{"prometheus.io/path":"/api/v1/metrics/prometheus","prometheus.io/port":"2020","prometheus.io/scrape":"true"},"host":"ip-10-49-18-80.eu-west-1.compute.internal","container_name":"fluent-bit","docker_id":"c9898099f6d235126d564ed38a020007ea7a6fac6e25e718de683c9dd0076c16","container_hash":"fluent/fluent-bit@sha256:7ac0fd3569af866e9a6a22eb592744200d2dbe098cf066162453f8d0b06c531f","container_image":"fluent/fluent-bit:latest"}}] diff --git a/tests/runtime/data/kubernetes/out/options/options_use-kubelet-enabled-daemonset_fluent-bit.out b/tests/runtime/data/kubernetes/out/options/options_use-kubelet-enabled-daemonset_fluent-bit.out index d9ce4885dcc..c7c52d3a545 100644 --- a/tests/runtime/data/kubernetes/out/options/options_use-kubelet-enabled-daemonset_fluent-bit.out +++ b/tests/runtime/data/kubernetes/out/options/options_use-kubelet-enabled-daemonset_fluent-bit.out @@ -1 +1 @@ -[1554141513.598656,{"log":"Fluent Bit is logging\n","stream":"stdout","kubernetes":{"pod_name":"use-kubelet-enabled-daemonset","namespace_name":"options","workload":"my-daemonset","pod_id":"e9f2963f-55f2-11e9-84c5-02e422b8a84a","labels":{"app.kubernetes.io/name":"fluent-bit"},"annotations":{"prometheus.io/path":"/api/v1/metrics/prometheus","prometheus.io/port":"2020","prometheus.io/scrape":"true"},"host":"ip-10-49-18-80.eu-west-1.compute.internal","container_name":"fluent-bit","docker_id":"c9898099f6d235126d564ed38a020007ea7a6fac6e25e718de683c9dd0076c16","container_hash":"fluent/fluent-bit@sha256:7ac0fd3569af866e9a6a22eb592744200d2dbe098cf066162453f8d0b06c531f","container_image":"fluent/fluent-bit:latest"}}] +[1554141513.598656,{"log":"Fluent Bit is logging\n","stream":"stdout","kubernetes":{"pod_name":"use-kubelet-enabled-daemonset","namespace_name":"options","aws_entity_workload":"my-daemonset","pod_id":"e9f2963f-55f2-11e9-84c5-02e422b8a84a","labels":{"app.kubernetes.io/name":"fluent-bit"},"annotations":{"prometheus.io/path":"/api/v1/metrics/prometheus","prometheus.io/port":"2020","prometheus.io/scrape":"true"},"host":"ip-10-49-18-80.eu-west-1.compute.internal","container_name":"fluent-bit","docker_id":"c9898099f6d235126d564ed38a020007ea7a6fac6e25e718de683c9dd0076c16","container_hash":"fluent/fluent-bit@sha256:7ac0fd3569af866e9a6a22eb592744200d2dbe098cf066162453f8d0b06c531f","container_image":"fluent/fluent-bit:latest"}}] diff --git a/tests/runtime/data/kubernetes/out/options/options_use-kubelet-enabled-deployment_fluent-bit.out b/tests/runtime/data/kubernetes/out/options/options_use-kubelet-enabled-deployment_fluent-bit.out index 0b7055a6e9e..7f91c9a7ee3 100644 --- a/tests/runtime/data/kubernetes/out/options/options_use-kubelet-enabled-deployment_fluent-bit.out +++ b/tests/runtime/data/kubernetes/out/options/options_use-kubelet-enabled-deployment_fluent-bit.out @@ -1 +1 @@ -[1554141513.598656,{"log":"Fluent Bit is logging\n","stream":"stdout","kubernetes":{"pod_name":"use-kubelet-enabled-deployment","namespace_name":"options","workload":"my-deployment","pod_id":"e9f2963f-55f2-11e9-84c5-02e422b8a84a","labels":{"app.kubernetes.io/name":"fluent-bit"},"annotations":{"prometheus.io/path":"/api/v1/metrics/prometheus","prometheus.io/port":"2020","prometheus.io/scrape":"true"},"host":"ip-10-49-18-80.eu-west-1.compute.internal","container_name":"fluent-bit","docker_id":"c9898099f6d235126d564ed38a020007ea7a6fac6e25e718de683c9dd0076c16","container_hash":"fluent/fluent-bit@sha256:7ac0fd3569af866e9a6a22eb592744200d2dbe098cf066162453f8d0b06c531f","container_image":"fluent/fluent-bit:latest"}}] +[1554141513.598656,{"log":"Fluent Bit is logging\n","stream":"stdout","kubernetes":{"pod_name":"use-kubelet-enabled-deployment","namespace_name":"options","aws_entity_workload":"my-deployment","pod_id":"e9f2963f-55f2-11e9-84c5-02e422b8a84a","labels":{"app.kubernetes.io/name":"fluent-bit"},"annotations":{"prometheus.io/path":"/api/v1/metrics/prometheus","prometheus.io/port":"2020","prometheus.io/scrape":"true"},"host":"ip-10-49-18-80.eu-west-1.compute.internal","container_name":"fluent-bit","docker_id":"c9898099f6d235126d564ed38a020007ea7a6fac6e25e718de683c9dd0076c16","container_hash":"fluent/fluent-bit@sha256:7ac0fd3569af866e9a6a22eb592744200d2dbe098cf066162453f8d0b06c531f","container_image":"fluent/fluent-bit:latest"}}] diff --git a/tests/runtime/data/kubernetes/out/options/options_use-kubelet-enabled-pod_fluent-bit.out b/tests/runtime/data/kubernetes/out/options/options_use-kubelet-enabled-pod_fluent-bit.out index ccc0d77b4d0..1a908691dfe 100644 --- a/tests/runtime/data/kubernetes/out/options/options_use-kubelet-enabled-pod_fluent-bit.out +++ b/tests/runtime/data/kubernetes/out/options/options_use-kubelet-enabled-pod_fluent-bit.out @@ -1 +1 @@ -[1554141513.598656,{"log":"Fluent Bit is logging\n","stream":"stdout","kubernetes":{"pod_name":"use-kubelet-enabled-pod","namespace_name":"options","workload":"use-kubelet-enabled-pod","pod_id":"e9f2963f-55f2-11e9-84c5-02e422b8a84a","labels":{"app.kubernetes.io/name":"fluent-bit"},"annotations":{"prometheus.io/path":"/api/v1/metrics/prometheus","prometheus.io/port":"2020","prometheus.io/scrape":"true"},"host":"ip-10-49-18-80.eu-west-1.compute.internal","container_name":"fluent-bit","docker_id":"c9898099f6d235126d564ed38a020007ea7a6fac6e25e718de683c9dd0076c16","container_hash":"fluent/fluent-bit@sha256:7ac0fd3569af866e9a6a22eb592744200d2dbe098cf066162453f8d0b06c531f","container_image":"fluent/fluent-bit:latest"}}] +[1554141513.598656,{"log":"Fluent Bit is logging\n","stream":"stdout","kubernetes":{"pod_name":"use-kubelet-enabled-pod","namespace_name":"options","aws_entity_workload":"use-kubelet-enabled-pod","pod_id":"e9f2963f-55f2-11e9-84c5-02e422b8a84a","labels":{"app.kubernetes.io/name":"fluent-bit"},"annotations":{"prometheus.io/path":"/api/v1/metrics/prometheus","prometheus.io/port":"2020","prometheus.io/scrape":"true"},"host":"ip-10-49-18-80.eu-west-1.compute.internal","container_name":"fluent-bit","docker_id":"c9898099f6d235126d564ed38a020007ea7a6fac6e25e718de683c9dd0076c16","container_hash":"fluent/fluent-bit@sha256:7ac0fd3569af866e9a6a22eb592744200d2dbe098cf066162453f8d0b06c531f","container_image":"fluent/fluent-bit:latest"}}] diff --git a/tests/runtime/data/kubernetes/out/options/options_use-kubelet-enabled-replicaset_fluent-bit.out b/tests/runtime/data/kubernetes/out/options/options_use-kubelet-enabled-replicaset_fluent-bit.out index cd9cfdb86ca..39a07949129 100644 --- a/tests/runtime/data/kubernetes/out/options/options_use-kubelet-enabled-replicaset_fluent-bit.out +++ b/tests/runtime/data/kubernetes/out/options/options_use-kubelet-enabled-replicaset_fluent-bit.out @@ -1 +1 @@ -[1554141513.598656,{"log":"Fluent Bit is logging\n","stream":"stdout","kubernetes":{"pod_name":"use-kubelet-enabled-replicaset","namespace_name":"options","workload":"my-replicaset","pod_id":"e9f2963f-55f2-11e9-84c5-02e422b8a84a","labels":{"app.kubernetes.io/name":"fluent-bit"},"annotations":{"prometheus.io/path":"/api/v1/metrics/prometheus","prometheus.io/port":"2020","prometheus.io/scrape":"true"},"host":"ip-10-49-18-80.eu-west-1.compute.internal","container_name":"fluent-bit","docker_id":"c9898099f6d235126d564ed38a020007ea7a6fac6e25e718de683c9dd0076c16","container_hash":"fluent/fluent-bit@sha256:7ac0fd3569af866e9a6a22eb592744200d2dbe098cf066162453f8d0b06c531f","container_image":"fluent/fluent-bit:latest"}}] +[1554141513.598656,{"log":"Fluent Bit is logging\n","stream":"stdout","kubernetes":{"pod_name":"use-kubelet-enabled-replicaset","namespace_name":"options","aws_entity_workload":"my-replicaset","pod_id":"e9f2963f-55f2-11e9-84c5-02e422b8a84a","labels":{"app.kubernetes.io/name":"fluent-bit"},"annotations":{"prometheus.io/path":"/api/v1/metrics/prometheus","prometheus.io/port":"2020","prometheus.io/scrape":"true"},"host":"ip-10-49-18-80.eu-west-1.compute.internal","container_name":"fluent-bit","docker_id":"c9898099f6d235126d564ed38a020007ea7a6fac6e25e718de683c9dd0076c16","container_hash":"fluent/fluent-bit@sha256:7ac0fd3569af866e9a6a22eb592744200d2dbe098cf066162453f8d0b06c531f","container_image":"fluent/fluent-bit:latest"}}] diff --git a/tests/runtime/data/kubernetes/out/options/options_use-pod-association-enabled-fallback-env_fluent-bit.out b/tests/runtime/data/kubernetes/out/options/options_use-pod-association-enabled-fallback-env_fluent-bit.out index 3a2a66d746a..090d13925a0 100644 --- a/tests/runtime/data/kubernetes/out/options/options_use-pod-association-enabled-fallback-env_fluent-bit.out +++ b/tests/runtime/data/kubernetes/out/options/options_use-pod-association-enabled-fallback-env_fluent-bit.out @@ -1 +1 @@ -[1554141513.598656,{"log":"Fluent Bit is logging\n","stream":"stdout","kubernetes":{"pod_name":"use-pod-association-enabled-fallback-env","namespace_name":"options","service_name":"test-service","environment":"eks:test-cluster/options","name_source":"Instrumentation","platform":"eks","cluster":"test-cluster","workload":"use-pod-association-enabled-fallback-env","pod_id":"e9f2963f-55f2-11e9-84c5-02e422b8a84a","labels":{"app.kubernetes.io/name":"fluent-bit"},"annotations":{"prometheus.io/path":"/api/v1/metrics/prometheus","prometheus.io/port":"2020","prometheus.io/scrape":"true"},"host":"ip-10-49-18-80.eu-west-1.compute.internal","container_name":"fluent-bit","docker_id":"c9898099f6d235126d564ed38a020007ea7a6fac6e25e718de683c9dd0076c16","container_hash":"fluent/fluent-bit@sha256:7ac0fd3569af866e9a6a22eb592744200d2dbe098cf066162453f8d0b06c531f","container_image":"fluent/fluent-bit:latest"}}] +[1554141513.598656,{"log":"Fluent Bit is logging\n","stream":"stdout","kubernetes":{"pod_name":"use-pod-association-enabled-fallback-env","namespace_name":"options","aws_entity_service_name":"test-service","aws_entity_environment":"eks:test-cluster/options","aws_entity_name_source":"Instrumentation","aws_entity_platform":"eks","aws_entity_cluster":"test-cluster","aws_entity_workload":"use-pod-association-enabled-fallback-env","pod_id":"e9f2963f-55f2-11e9-84c5-02e422b8a84a","labels":{"app.kubernetes.io/name":"fluent-bit"},"annotations":{"prometheus.io/path":"/api/v1/metrics/prometheus","prometheus.io/port":"2020","prometheus.io/scrape":"true"},"host":"ip-10-49-18-80.eu-west-1.compute.internal","container_name":"fluent-bit","docker_id":"c9898099f6d235126d564ed38a020007ea7a6fac6e25e718de683c9dd0076c16","container_hash":"fluent/fluent-bit@sha256:7ac0fd3569af866e9a6a22eb592744200d2dbe098cf066162453f8d0b06c531f","container_image":"fluent/fluent-bit:latest"}}] diff --git a/tests/runtime/data/kubernetes/out/options/options_use-pod-association-enabled_fluent-bit.out b/tests/runtime/data/kubernetes/out/options/options_use-pod-association-enabled_fluent-bit.out index 4b1ec144601..a6c93217216 100644 --- a/tests/runtime/data/kubernetes/out/options/options_use-pod-association-enabled_fluent-bit.out +++ b/tests/runtime/data/kubernetes/out/options/options_use-pod-association-enabled_fluent-bit.out @@ -1 +1 @@ -[1554141513.598656,{"log":"Fluent Bit is logging\n","stream":"stdout","kubernetes":{"pod_name":"use-pod-association-enabled","namespace_name":"options","service_name":"test-service","environment":"test-environment","name_source":"Instrumentation","workload":"use-pod-association-enabled","pod_id":"e9f2963f-55f2-11e9-84c5-02e422b8a84a","labels":{"app.kubernetes.io/name":"fluent-bit"},"annotations":{"prometheus.io/path":"/api/v1/metrics/prometheus","prometheus.io/port":"2020","prometheus.io/scrape":"true"},"host":"ip-10-49-18-80.eu-west-1.compute.internal","container_name":"fluent-bit","docker_id":"c9898099f6d235126d564ed38a020007ea7a6fac6e25e718de683c9dd0076c16","container_hash":"fluent/fluent-bit@sha256:7ac0fd3569af866e9a6a22eb592744200d2dbe098cf066162453f8d0b06c531f","container_image":"fluent/fluent-bit:latest"}}] +[1554141513.598656,{"log":"Fluent Bit is logging\n","stream":"stdout","kubernetes":{"pod_name":"use-pod-association-enabled","namespace_name":"options","aws_entity_service_name":"test-service","aws_entity_environment":"test-environment","aws_entity_name_source":"Instrumentation","aws_entity_workload":"use-pod-association-enabled","pod_id":"e9f2963f-55f2-11e9-84c5-02e422b8a84a","labels":{"app.kubernetes.io/name":"fluent-bit"},"annotations":{"prometheus.io/path":"/api/v1/metrics/prometheus","prometheus.io/port":"2020","prometheus.io/scrape":"true"},"host":"ip-10-49-18-80.eu-west-1.compute.internal","container_name":"fluent-bit","docker_id":"c9898099f6d235126d564ed38a020007ea7a6fac6e25e718de683c9dd0076c16","container_hash":"fluent/fluent-bit@sha256:7ac0fd3569af866e9a6a22eb592744200d2dbe098cf066162453f8d0b06c531f","container_image":"fluent/fluent-bit:latest"}}] diff --git a/tests/runtime/filter_kubernetes.c b/tests/runtime/filter_kubernetes.c index 02979f0e808..2524450c185 100644 --- a/tests/runtime/filter_kubernetes.c +++ b/tests/runtime/filter_kubernetes.c @@ -1003,12 +1003,6 @@ static void kube_options_use_pod_association_enabled() flb_test_pod_to_service_map_use_kubelet_true("options_use-pod-association-enabled_fluent-bit", NULL, 1, NULL); } -static void kube_options_use_pod_association_enabled_fallback_env() -{ - setenv("CLUSTER_NAME","test-cluster", 1); - flb_test_pod_to_service_map_use_kubelet_true("options_use-pod-association-enabled-fallback-env_fluent-bit", NULL, 1, "eks"); -} - #ifdef FLB_HAVE_SYSTEMD #define CONTAINER_NAME "CONTAINER_NAME=k8s_kairosdb_kairosdb-914055854-b63vq_default_d6c53deb-05a4-11e8-a8c4-080027435fb7_23" #include @@ -1100,7 +1094,6 @@ TEST_LIST = { {"kube_core_unescaping_text", flb_test_core_unescaping_text}, {"kube_core_unescaping_json", flb_test_core_unescaping_json}, {"kube_options_use_pod_association_enabled", kube_options_use_pod_association_enabled}, - {"kube_options_use_pod_association_enabled_fallback_env", kube_options_use_pod_association_enabled_fallback_env}, {"kube_options_use-kubelet_enabled_json", flb_test_options_use_kubelet_enabled_json}, {"kube_options_use-kubelet_enabled_replicateset_json", flb_test_options_use_kubelet_enabled_replicaset_json}, {"kube_options_use-kubelet_enabled_deployment_json", flb_test_options_use_kubelet_enabled_deployment_json},