File tree Expand file tree Collapse file tree 1 file changed +17
-0
lines changed Expand file tree Collapse file tree 1 file changed +17
-0
lines changed Original file line number Diff line number Diff line change @@ -149,6 +149,19 @@ static void out_lib_flush(struct flb_event_chunk *event_chunk,
149149 data_size = alloc_size ;
150150 break ;
151151 case FLB_OUT_LIB_FMT_JSON :
152+ #ifdef FLB_HAVE_METRICS
153+ if (event_chunk -> type == FLB_EVENT_TYPE_METRIC ) {
154+ alloc_size = (off - last_off ) + 4096 ;
155+ buf = flb_msgpack_to_json_str (alloc_size , & result .data );
156+ if (buf == NULL ) {
157+ msgpack_unpacked_destroy (& result );
158+ FLB_OUTPUT_RETURN (FLB_ERROR );
159+ }
160+ data_size = strlen (buf );
161+ data_for_user = buf ;
162+ }
163+ else {
164+ #endif
152165 /* JSON is larger than msgpack */
153166 alloc_size = (off - last_off ) + 128 ;
154167
@@ -174,6 +187,9 @@ static void out_lib_flush(struct flb_event_chunk *event_chunk,
174187 flb_free (buf );
175188 data_for_user = out_buf ;
176189 data_size = len ;
190+ #ifdef FLB_HAVE_METRICS
191+ }
192+ #endif
177193 break ;
178194 }
179195
@@ -201,5 +217,6 @@ struct flb_output_plugin out_lib_plugin = {
201217 .cb_init = out_lib_init ,
202218 .cb_flush = out_lib_flush ,
203219 .cb_exit = out_lib_exit ,
220+ .event_type = FLB_OUTPUT_LOGS | FLB_OUTPUT_METRICS ,
204221 .flags = 0 ,
205222};
You can’t perform that action at this time.
0 commit comments