Skip to content

Commit 4cfca0c

Browse files
out_cloudwatch_logs: Added StorageResolution support for EMF
Signed-off-by: Devin Stafford <[email protected]>
1 parent 455fc22 commit 4cfca0c

File tree

3 files changed

+22
-1
lines changed

3 files changed

+22
-1
lines changed

plugins/out_cloudwatch_logs/cloudwatch_api.c

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -750,7 +750,7 @@ int pack_emf_payload(struct flb_cloudwatch *ctx,
750750
mk_list_foreach_safe(metric_head, metric_temp, flb_intermediate_metrics) {
751751
an_item = mk_list_entry(metric_head, struct flb_intermediate_metric, _head);
752752
if (should_add_to_emf(an_item) == 1) {
753-
msgpack_pack_map(&mp_pck, 2);
753+
msgpack_pack_map(&mp_pck, 3);
754754
msgpack_pack_str(&mp_pck, 4);
755755
msgpack_pack_str_body(&mp_pck, "Name", 4);
756756
msgpack_pack_object(&mp_pck, an_item->key);
@@ -759,6 +759,9 @@ int pack_emf_payload(struct flb_cloudwatch *ctx,
759759
msgpack_pack_str(&mp_pck, strlen(an_item->metric_unit));
760760
msgpack_pack_str_body(&mp_pck, an_item->metric_unit,
761761
strlen(an_item->metric_unit));
762+
msgpack_pack_str(&mp_pck, 17);
763+
msgpack_pack_str_body(&mp_pck, "StorageResolution", 17);
764+
msgpack_pack_int(&mp_pck, ctx->metric_storage_resolution);
762765
}
763766
}
764767

plugins/out_cloudwatch_logs/cloudwatch_logs.c

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -208,6 +208,16 @@ static int cb_cloudwatch_init(struct flb_output_instance *ins,
208208
ctx->metric_dimensions = flb_utils_split(tmp, ';', 256);
209209
}
210210

211+
tmp = flb_output_get_property("metric_storage_resolution", ins);
212+
if (tmp)
213+
{
214+
flb_plg_info(ctx->ins, "Metric Storage Resolution=%s", tmp);
215+
ctx->metric_storage_resolution = atoi(tmp);
216+
} else {
217+
/* Default to 60s storage resolution as does CloudWatch if not specified */
218+
ctx->metric_storage_resolution = 60;
219+
}
220+
211221
ctx->create_group = FLB_FALSE;
212222
tmp = flb_output_get_property("auto_create_group", ins);
213223
if (tmp) {
@@ -676,6 +686,12 @@ static struct flb_config_map config_map[] = {
676686
"is 'd1,d2;d3', we will consider it as [[d1, d2],[d3]]."
677687
},
678688

689+
{
690+
FLB_CONFIG_MAP_STR, "metric_storage_resolution", NULL,
691+
0, FLB_FALSE, 0,
692+
"Metric storage resolution for CloudWatch EMF logs"
693+
},
694+
679695
{
680696
FLB_CONFIG_MAP_STR, "profile", NULL,
681697
0, FLB_TRUE, offsetof(struct flb_cloudwatch, profile),

plugins/out_cloudwatch_logs/cloudwatch_logs.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -157,6 +157,8 @@ struct flb_cloudwatch {
157157
is 'd1,d2;d3', we will consider it as [[d1, d2],[d3]]*/
158158
struct mk_list *metric_dimensions;
159159

160+
int metric_storage_resolution;
161+
160162
/* Plugin output instance reference */
161163
struct flb_output_instance *ins;
162164
};

0 commit comments

Comments
 (0)