Skip to content

Commit 4311417

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

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
@@ -808,6 +808,11 @@ int flb_pack_to_json_date_type(const char *str)
808808
else if (strcasecmp(str, "epoch") == 0) {
809809
return FLB_PACK_JSON_DATE_EPOCH;
810810
}
811+
else if (strcasecmp(str, "epoch_ms") == 0 ||
812+
strcasecmp(str, "epoch_millis") == 0 ||
813+
strcasecmp(str, "epoch_milliseconds") == 0) {
814+
return FLB_PACK_JSON_DATE_EPOCH_MS;
815+
}
811816

812817
return -1;
813818
}
@@ -942,6 +947,11 @@ flb_sds_t flb_pack_msgpack_to_json_format(const char *data, uint64_t bytes,
942947
case FLB_PACK_JSON_DATE_EPOCH:
943948
msgpack_pack_uint64(&tmp_pck, (long long unsigned)(tms.tm.tv_sec));
944949
break;
950+
case FLB_PACK_JSON_DATE_EPOCH_MS:
951+
msgpack_pack_uint64(&tmp_pck,
952+
(long long unsigned)(tms.tm.tv_sec) * 1000 +
953+
tms.tm.tv_nsec / 1000000);
954+
break;
945955
}
946956
}
947957

0 commit comments

Comments
 (0)