diff --git a/plugins/out_cloudwatch_logs/cloudwatch_api.c b/plugins/out_cloudwatch_logs/cloudwatch_api.c index 276671204b0..b7861e4aa5f 100644 --- a/plugins/out_cloudwatch_logs/cloudwatch_api.c +++ b/plugins/out_cloudwatch_logs/cloudwatch_api.c @@ -750,7 +750,7 @@ int pack_emf_payload(struct flb_cloudwatch *ctx, mk_list_foreach_safe(metric_head, metric_temp, flb_intermediate_metrics) { an_item = mk_list_entry(metric_head, struct flb_intermediate_metric, _head); if (should_add_to_emf(an_item) == 1) { - msgpack_pack_map(&mp_pck, 2); + msgpack_pack_map(&mp_pck, 3); msgpack_pack_str(&mp_pck, 4); msgpack_pack_str_body(&mp_pck, "Name", 4); msgpack_pack_object(&mp_pck, an_item->key); @@ -759,6 +759,9 @@ int pack_emf_payload(struct flb_cloudwatch *ctx, msgpack_pack_str(&mp_pck, strlen(an_item->metric_unit)); msgpack_pack_str_body(&mp_pck, an_item->metric_unit, strlen(an_item->metric_unit)); + msgpack_pack_str(&mp_pck, 17); + msgpack_pack_str_body(&mp_pck, "StorageResolution", 17); + msgpack_pack_int(&mp_pck, ctx->metric_storage_resolution); } } diff --git a/plugins/out_cloudwatch_logs/cloudwatch_logs.c b/plugins/out_cloudwatch_logs/cloudwatch_logs.c index c5e808ae141..54a0dfc577d 100644 --- a/plugins/out_cloudwatch_logs/cloudwatch_logs.c +++ b/plugins/out_cloudwatch_logs/cloudwatch_logs.c @@ -195,19 +195,26 @@ static int cb_cloudwatch_init(struct flb_output_instance *ins, } tmp = flb_output_get_property("metric_namespace", ins); - if (tmp) - { + if (tmp) { flb_plg_info(ctx->ins, "Metric Namespace=%s", tmp); ctx->metric_namespace = flb_sds_create(tmp); } tmp = flb_output_get_property("metric_dimensions", ins); - if (tmp) - { + if (tmp) { flb_plg_info(ctx->ins, "Metric Dimensions=%s", tmp); ctx->metric_dimensions = flb_utils_split(tmp, ';', 256); } + tmp = flb_output_get_property("metric_storage_resolution", ins); + if (tmp) { + flb_plg_info(ctx->ins, "Metric Storage Resolution=%s", tmp); + ctx->metric_storage_resolution = atoi(tmp); + } else { + /* Default to 60s storage resolution as does CloudWatch if not specified */ + ctx->metric_storage_resolution = 60; + } + ctx->create_group = FLB_FALSE; tmp = flb_output_get_property("auto_create_group", ins); if (tmp) { @@ -676,6 +683,12 @@ static struct flb_config_map config_map[] = { "is 'd1,d2;d3', we will consider it as [[d1, d2],[d3]]." }, + { + FLB_CONFIG_MAP_STR, "metric_storage_resolution", NULL, + 0, FLB_FALSE, 0, + "Metric storage resolution for CloudWatch EMF logs" + }, + { FLB_CONFIG_MAP_STR, "profile", NULL, 0, FLB_TRUE, offsetof(struct flb_cloudwatch, profile), diff --git a/plugins/out_cloudwatch_logs/cloudwatch_logs.h b/plugins/out_cloudwatch_logs/cloudwatch_logs.h index 3724863426a..2c5b0ff255f 100644 --- a/plugins/out_cloudwatch_logs/cloudwatch_logs.h +++ b/plugins/out_cloudwatch_logs/cloudwatch_logs.h @@ -157,6 +157,8 @@ struct flb_cloudwatch { is 'd1,d2;d3', we will consider it as [[d1, d2],[d3]]*/ struct mk_list *metric_dimensions; + int metric_storage_resolution; + /* Plugin output instance reference */ struct flb_output_instance *ins; };