@@ -152,6 +152,7 @@ struct flb_parser *flb_parser_create(const char *name, const char *format,
152152 const char * time_offset ,
153153 int time_keep ,
154154 int time_strict ,
155+ int time_system_timezone ,
155156 int logfmt_no_bare_keys ,
156157 struct flb_parser_types * types ,
157158 int types_len ,
@@ -312,8 +313,17 @@ struct flb_parser *flb_parser_create(const char *name, const char *format,
312313 p -> time_frac_secs = (tmp + 2 );
313314 }
314315
315- /* Optional fixed timezone offset */
316- if (time_offset ) {
316+ /*
317+ * Fall back to the system timezone
318+ * if there is no zone parsed from the log.
319+ */
320+ p -> time_system_timezone = time_system_timezone ;
321+
322+ /*
323+ * Optional fixed timezone offset, only applied if
324+ * not falling back to system timezone.
325+ */
326+ if (!p -> time_system_timezone && time_offset ) {
317327 diff = 0 ;
318328 len = strlen (time_offset );
319329 ret = flb_parser_tzone_offset (time_offset , len , & diff );
@@ -487,6 +497,7 @@ static int parser_conf_file(const char *cfg, struct flb_cf *cf,
487497 int skip_empty ;
488498 int time_keep ;
489499 int time_strict ;
500+ int time_system_timezone ;
490501 int logfmt_no_bare_keys ;
491502 int types_len ;
492503 struct mk_list * head ;
@@ -561,6 +572,13 @@ static int parser_conf_file(const char *cfg, struct flb_cf *cf,
561572 flb_sds_destroy (tmp_str );
562573 }
563574
575+ time_system_timezone = FLB_FALSE ;
576+ tmp_str = get_parser_key (config , cf , s , "time_system_timezone" );
577+ if (tmp_str ) {
578+ time_system_timezone = flb_utils_bool (tmp_str );
579+ flb_sds_destroy (tmp_str );
580+ }
581+
564582 /* time_offset (UTC offset) */
565583 time_offset = get_parser_key (config , cf , s , "time_offset" );
566584
@@ -587,7 +605,8 @@ static int parser_conf_file(const char *cfg, struct flb_cf *cf,
587605 /* Create the parser context */
588606 if (!flb_parser_create (name , format , regex , skip_empty ,
589607 time_fmt , time_key , time_offset , time_keep , time_strict ,
590- logfmt_no_bare_keys , types , types_len , decoders , config )) {
608+ time_system_timezone , logfmt_no_bare_keys , types , types_len ,
609+ decoders , config )) {
591610 goto fconf_error ;
592611 }
593612
0 commit comments