Skip to content

Commit 9c7469e

Browse files
committed
pack: add 'epoch_ms' format
Signed-off-by: Jeongki Kim <[email protected]>
1 parent 9ec4344 commit 9c7469e

File tree

2 files changed

+11
-0
lines changed

2 files changed

+11
-0
lines changed

include/fluent-bit/flb_pack.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@
3939
#define FLB_PACK_JSON_DATE_ISO8601 1
4040
#define FLB_PACK_JSON_DATE_EPOCH 2
4141
#define FLB_PACK_JSON_DATE_JAVA_SQL_TIMESTAMP 3
42+
#define FLB_PACK_JSON_DATE_EPOCH_MS 4
4243

4344
/* Specific ISO8601 format */
4445
#define FLB_PACK_JSON_DATE_ISO8601_FMT "%Y-%m-%dT%H:%M:%S"

src/flb_pack.c

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -817,6 +817,11 @@ int flb_pack_to_json_date_type(const char *str)
817817
else if (strcasecmp(str, "epoch") == 0) {
818818
return FLB_PACK_JSON_DATE_EPOCH;
819819
}
820+
else if (strcasecmp(str, "epoch_ms") == 0 ||
821+
strcasecmp(str, "epoch_millis") == 0 ||
822+
strcasecmp(str, "epoch_milliseconds") == 0) {
823+
return FLB_PACK_JSON_DATE_EPOCH_MS;
824+
}
820825

821826
return -1;
822827
}
@@ -951,6 +956,11 @@ flb_sds_t flb_pack_msgpack_to_json_format(const char *data, uint64_t bytes,
951956
case FLB_PACK_JSON_DATE_EPOCH:
952957
msgpack_pack_uint64(&tmp_pck, (long long unsigned)(tms.tm.tv_sec));
953958
break;
959+
case FLB_PACK_JSON_DATE_EPOCH_MS:
960+
msgpack_pack_uint64(&tmp_pck,
961+
(long long unsigned)(tms.tm.tv_sec) * 1000 +
962+
tms.tm.tv_nsec / 1000000);
963+
break;
954964
}
955965
}
956966

0 commit comments

Comments
 (0)