@@ -530,38 +530,58 @@ int azure_kusto_streaming_ingestion(struct flb_azure_kusto *ctx, flb_sds_t tag,
530530 struct tm tm ;
531531 char tmp [64 ];
532532 int len ;
533+ size_t size_limit ;
533534
534535 flb_plg_info (ctx -> ins , "[STREAMING_INGESTION] Starting for tag: %.*s, payload: %zu bytes, db: %s, table: %s, compression: %s" ,
535536 (int )tag_len , tag , payload_size , ctx -> database_name , ctx -> table_name , ctx -> compression_enabled ? "enabled" : "disabled" );
536537
538+ /*
539+ * Size validation (matching ManagedStreamingIngestClient behavior)
540+ * Check payload size against limits before attempting streaming ingestion
541+ */
542+ if (ctx -> compression_enabled ) {
543+ size_limit = KUSTO_STREAMING_MAX_COMPRESSED_SIZE ;
544+ } else {
545+ size_limit = KUSTO_STREAMING_MAX_UNCOMPRESSED_SIZE ;
546+ }
547+
548+ if (payload_size > size_limit ) {
549+ flb_plg_warn (ctx -> ins , "[STREAMING_INGESTION] Payload size %zu bytes exceeds %s limit of %zu bytes - falling back to queued ingestion" ,
550+ payload_size , ctx -> compression_enabled ? "compressed" : "uncompressed" , size_limit );
551+
552+ /* Fallback to queued ingestion */
553+ ret = azure_kusto_queued_ingestion (ctx , tag , tag_len , payload , payload_size , NULL );
554+ if (ret == 0 ) {
555+ flb_plg_info (ctx -> ins , "[STREAMING_INGESTION] Successfully fell back to queued ingestion" );
556+ } else {
557+ flb_plg_error (ctx -> ins , "[STREAMING_INGESTION] Fallback to queued ingestion failed" );
558+ }
559+ return ret ;
560+ }
561+
537562 now = time (NULL );
538563 gmtime_r (& now , & tm );
539564 len = strftime (tmp , sizeof (tmp ) - 1 , "%a, %d %b %Y %H:%M:%S GMT" , & tm );
540- flb_plg_debug (ctx -> ins , "[STREAMING_INGESTION] Request timestamp: %s" , tmp );
541565
542566 /* Get upstream connection to the main Kusto cluster endpoint (for streaming ingestion) */
543567 if (!ctx -> u_cluster ) {
544568 flb_plg_error (ctx -> ins , "[STREAMING_INGESTION] ERROR: cluster upstream not available - streaming ingestion requires cluster endpoint" );
545569 return -1 ;
546570 }
547571
548- flb_plg_debug (ctx -> ins , "[STREAMING_INGESTION] Getting upstream connection to cluster endpoint" );
549572 u_conn = flb_upstream_conn_get (ctx -> u_cluster );
550573 if (!u_conn ) {
551574 flb_plg_error (ctx -> ins , "[STREAMING_INGESTION] ERROR: failed to get cluster upstream connection" );
552575 return -1 ;
553576 }
554- flb_plg_debug (ctx -> ins , "[STREAMING_INGESTION] Successfully obtained upstream connection" );
555577
556578 /* Get authentication token */
557- flb_plg_debug (ctx -> ins , "[STREAMING_INGESTION] Retrieving OAuth2 authentication token" );
558579 token = get_azure_kusto_token (ctx );
559580 if (!token ) {
560581 flb_plg_error (ctx -> ins , "[STREAMING_INGESTION] ERROR: failed to retrieve OAuth2 token" );
561582 flb_upstream_conn_release (u_conn );
562583 return -1 ;
563584 }
564- flb_plg_debug (ctx -> ins , "[STREAMING_INGESTION] Successfully obtained OAuth2 token (length: %zu)" , flb_sds_len (token ));
565585
566586 /* Build the streaming ingestion URI */
567587 uri = flb_sds_create_size (256 );
@@ -577,17 +597,14 @@ int azure_kusto_streaming_ingestion(struct flb_azure_kusto *ctx, flb_sds_t tag,
577597 flb_sds_snprintf (& uri , flb_sds_alloc (uri ),
578598 "/v1/rest/ingest/%s/%s?streamFormat=MultiJSON&mappingName=%s" ,
579599 ctx -> database_name , ctx -> table_name , ctx -> ingestion_mapping_reference );
580- flb_plg_debug (ctx -> ins , "[STREAMING_INGESTION] Using ingestion mapping: %s" , ctx -> ingestion_mapping_reference );
581600 } else {
582601 flb_sds_snprintf (& uri , flb_sds_alloc (uri ),
583602 "/v1/rest/ingest/%s/%s?streamFormat=MultiJSON" ,
584603 ctx -> database_name , ctx -> table_name );
585604 flb_plg_debug (ctx -> ins , "[STREAMING_INGESTION] No ingestion mapping specified" );
586605 }
587- flb_plg_info (ctx -> ins , "[STREAMING_INGESTION] Request URI: %s" , uri );
588606
589607 /* Create HTTP client for streaming ingestion */
590- flb_plg_debug (ctx -> ins , "[STREAMING_INGESTION] Creating HTTP client for POST request" );
591608 c = flb_http_client (u_conn , FLB_HTTP_POST , uri , payload , payload_size ,
592609 NULL , 0 , NULL , 0 );
593610
@@ -605,15 +622,10 @@ int azure_kusto_streaming_ingestion(struct flb_azure_kusto *ctx, flb_sds_t tag,
605622 if (ctx -> compression_enabled ) {
606623 flb_http_add_header (c , "Content-Type" , 12 , "application/json" , 16 );
607624 flb_http_add_header (c , "Content-Encoding" , 16 , "gzip" , 4 );
608- flb_plg_debug (ctx -> ins , "[STREAMING_INGESTION] Headers set for compressed payload" );
609625 } else {
610626 flb_http_add_header (c , "Content-Type" , 12 , "application/json; charset=utf-8" , 31 );
611- flb_plg_debug (ctx -> ins , "[STREAMING_INGESTION] Headers set for uncompressed payload" );
612627 }
613628
614- flb_plg_debug (ctx -> ins , "[STREAMING_INGESTION] Payload sample (first 200 chars): %.200s" , (char * )payload );
615- flb_plg_info (ctx -> ins , "[STREAMING_INGESTION] Sending HTTP POST request to Kusto engine" );
616-
617629 /* Send the HTTP request */
618630 ret = flb_http_do (c , & resp_size );
619631
@@ -623,7 +635,6 @@ int azure_kusto_streaming_ingestion(struct flb_azure_kusto *ctx, flb_sds_t tag,
623635 /* Check for successful HTTP status codes */
624636 if (c -> resp .status == 200 || c -> resp .status == 204 ) {
625637 ret = 0 ;
626- flb_plg_info (ctx -> ins , "[STREAMING_INGESTION] SUCCESS: Data successfully ingested to Kusto (HTTP %d)" , c -> resp .status );
627638 } else {
628639 ret = -1 ;
629640 flb_plg_error (ctx -> ins , "[STREAMING_INGESTION] ERROR: HTTP request failed with status: %i" , c -> resp .status );
@@ -637,14 +648,12 @@ int azure_kusto_streaming_ingestion(struct flb_azure_kusto *ctx, flb_sds_t tag,
637648 flb_plg_error (ctx -> ins , "[STREAMING_INGESTION] ERROR: HTTP request failed at transport level (ret=%d)" , ret );
638649 }
639650
640- flb_plg_debug (ctx -> ins , "[STREAMING_INGESTION] Destroying HTTP client" );
641651 flb_http_client_destroy (c );
642652 } else {
643653 flb_plg_error (ctx -> ins , "[STREAMING_INGESTION] ERROR: failed to create HTTP client context" );
644654 }
645655
646656 /* Cleanup */
647- flb_plg_debug (ctx -> ins , "[STREAMING_INGESTION] Cleaning up resources" );
648657 if (uri ) {
649658 flb_sds_destroy (uri );
650659 }
@@ -653,7 +662,6 @@ int azure_kusto_streaming_ingestion(struct flb_azure_kusto *ctx, flb_sds_t tag,
653662 }
654663 flb_upstream_conn_release (u_conn );
655664
656- flb_plg_info (ctx -> ins , "[STREAMING_INGESTION] Streaming ingestion completed with result: %d" , ret );
657665 return ret ;
658666}
659667
0 commit comments