@@ -68,7 +68,8 @@ static int cb_doris_init(struct flb_output_instance *ins,
68
68
static int http_put (struct flb_out_doris * ctx ,
69
69
const char * host , int port ,
70
70
const void * body , size_t body_len ,
71
- const char * tag , int tag_len )
71
+ const char * tag , int tag_len ,
72
+ const char * label , int label_len )
72
73
{
73
74
int ret ;
74
75
int out_ret = FLB_OK ;
@@ -134,6 +135,11 @@ static int http_put(struct flb_out_doris *ctx,
134
135
flb_http_add_header (c , "strip_outer_array" , 17 , "true" , 4 );
135
136
flb_http_add_header (c , "User-Agent" , 10 , "Fluent-Bit" , 10 );
136
137
138
+ if (ctx -> add_label ) {
139
+ flb_http_add_header (c , "label" , 5 , label , label_len );
140
+ flb_plg_debug (ctx -> ins , "add label: %s" , label );
141
+ }
142
+
137
143
flb_config_map_foreach (head , mv , ctx -> headers ) {
138
144
key = mk_list_entry_first (mv -> val .list , struct flb_slist_entry , _head );
139
145
val = mk_list_entry_last (mv -> val .list , struct flb_slist_entry , _head );
@@ -170,7 +176,7 @@ static int http_put(struct flb_out_doris *ctx,
170
176
memcpy (redict_port , mid + 1 , end - (mid + 1 ));
171
177
172
178
out_ret = http_put (ctx , redict_host , atoi (redict_port ),
173
- body , body_len , tag , tag_len );
179
+ body , body_len , tag , tag_len , label , label_len );
174
180
}
175
181
else if (c -> resp .status == 200 && c -> resp .payload_size > 0 ) {
176
182
ret = flb_pack_json (c -> resp .payload , c -> resp .payload_size ,
@@ -296,6 +302,9 @@ static void cb_doris_flush(struct flb_event_chunk *event_chunk,
296
302
size_t out_size ;
297
303
(void ) i_ins ;
298
304
305
+ char label [256 ] = {0 };
306
+ int len = 0 ;
307
+
299
308
ret = compose_payload (ctx , event_chunk -> data , event_chunk -> size ,
300
309
& out_body , & out_size );
301
310
@@ -306,8 +315,14 @@ static void cb_doris_flush(struct flb_event_chunk *event_chunk,
306
315
FLB_OUTPUT_RETURN (ret );
307
316
}
308
317
318
+ if (ctx -> add_label ) {
319
+ len = snprintf (label , sizeof (label ) - 1 , "%s_%lu_" , ctx -> label_prefix , cfl_time_now () / 1000000000L );
320
+ flb_utils_uuid_v4_gen (label + len );
321
+ len += 36 ;
322
+ }
323
+
309
324
ret = http_put (ctx , ctx -> host , ctx -> port , out_body , out_size ,
310
- event_chunk -> tag , flb_sds_len (event_chunk -> tag ));
325
+ event_chunk -> tag , flb_sds_len (event_chunk -> tag ), label , len );
311
326
flb_sds_destroy (out_body );
312
327
313
328
if (ret == FLB_OK ) {
@@ -353,6 +368,12 @@ static struct flb_config_map config_map[] = {
353
368
0 , FLB_TRUE , offsetof(struct flb_out_doris , table ),
354
369
"Set table"
355
370
},
371
+ // label_prefix
372
+ {
373
+ FLB_CONFIG_MAP_STR , "label_prefix" , "flubentbit" ,
374
+ 0 , FLB_TRUE , offsetof(struct flb_out_doris , label_prefix ),
375
+ "Set label prefix"
376
+ },
356
377
// time_key
357
378
{
358
379
FLB_CONFIG_MAP_STR , "time_key" , "date" ,
0 commit comments