From Eventstream to KQL Database: Sub-Second Real-Time Analytics in Microsoft Fabric
From the publisher’s feed, collected in the ZeroLabs newsroom.
When we reflect on the historical evolution of our enterprise data platforms, we immediately recognize that our legacy architectures were fundamentally designed for batch processing. For years, we spent our days engineering robust nightly ETL pipelines, meticulously extracting data from operational systems at midnight, and loading it into analytical warehouses by dawn. We built a culture around “yesterday’s data.” However, as digital transformation accelerates, our business stakeholders demand unprecedented agility. In modern data architectures, speed and integration are no longer a luxury, but a necessity.We are witnessing a paradigm shift across every industry. We are moving decisively from static batch reporting to real-time, event-driven intelligence. Whether we are tracking global logistics, monitoring millions of IoT sensors on a manufacturing floor, or processing live market signals for a trading desk, the value of our data degrades exponentially with every passing second.To meet this critical demand, Microsoft Fabric introduces Real-Time Intelligence (RTI). This provides us with a high-throughput engine specifically optimized for log, event, and telemetry ingestion. In this comprehensive guide, we will explore how we can seamlessly ingest high-velocity data using Fabric Eventstream, route it natively to a KQL (Kusto Query Language) Database, and execute complex time-series aggregations and anomaly detection in under 500 milliseconds.Let us dive deep into the architecture of real-time streaming and unlock the power of sub-second analytics.Connecting Kafka, Event Hubs, or Custom AppsTo build a real-time analytics pipeline, we first need a highly scalable ingestion gateway. In legacy cloud architectures, this step alone required us to provision complex, dedicated messaging clusters, manage partition keys, and write custom consumer microservices. Within Microsoft Fabric, we dramatically simplify this process by leveraging the native Eventstream artifact.Fabric Eventstream acts as the central nervous system for our real-time data estate. It provides us with a fully managed, no-code/low-code routing environment that can seamlessly ingest millions of events per second without requiring us to manage any underlying infrastructure.When we initiate a new Eventstream in our Fabric workspace, we are presented with a highly intuitive, visual canvas. First, we define our source. If our organization is already deeply invested in the broader Azure ecosystem, we can effortlessly connect our Eventstream to an existing Azure Event Hub or Azure IoT Hub. If our engineering teams utilize open-source streaming platforms, we can easily wire up Apache Kafka topics. Furthermore, if we are building custom applications, we can push telemetry directly to the Eventstream using a custom app endpoint, establishing a direct, high-throughput ingestion channel.Once we configure the source, the magic of the Eventstream canvas becomes apparent. We immediately see a live data preview flowing through our browser, validating that our JSON telemetry payloads are successfully reaching the Fabric environment.From here, we must define our destination. While we could theoretically route this streaming data into a standard Lakehouse, our goal today is sub-second analytical querying. Therefore, we will confidently select a Fabric KQL Database as our final destination. The Eventstream handles the complex micro-batching and continuous delivery in the background, ensuring our telemetry lands in the KQL Database with absolute minimal latency.KQL Engine vs. Lakehouse SQL AnalyticsAt this juncture, a critical architectural question often arises among our engineering teams: Why are we using a KQL Database? If Microsoft Fabric is built entirely around OneLake and open Delta Parquet tables, why do we not simply stream our data into the Lakehouse and query it using the built-in SQL Analytics Endpoint?To build highly performant data platforms, we must match the correct compute engine to the specific workload. While the Fabric Lakehouse is phenomenally powerful for large-scale machine learning, historical data warehousing, and heavy batch transformations, it is not inherently designed for sub-second, highly volatile, append-only telemetry streams. Delta Parquet files require continuous compaction and optimization; constantly writing micro-files every few milliseconds can lead to severe performance degradation known as the “small file problem.”This is precisely where the KQL (Kusto Query Language) Database shines. The Kusto engine was purpose-built by Microsoft to ingest massive volumes of streaming data and provide near-instantaneous query responses. It achieves this blazing speed through a unique combination of in-memory caching, advanced columnar storage, and automatic text indexing.When an event lands in our KQL Database, the engine instantly indexes every single column, including deeply nested JSON attributes and full-text strings. This means that when we execute a query searching for a specific DeviceId or scanning for an error code within a raw log message, the engine does not perform a heavy, full-table scan. Instead, it utilizes the index to pinpoint the exact records instantly.Furthermore, the KQL engine is fundamentally optimized for time-series analytics. It handles sliding windows, temporal joins, and time-based aggregations with unparalleled efficiency. When we are building a real-time stocks intelligence platform where market movement and contextual enrichment occur in milliseconds, the KQL Database is our definitive engine of choice. We reserve our Lakehouse for our historical, curated batch data, and we deploy our KQL Database for our live, high-velocity operational telemetry.Ingestion & ProcessingTo demonstrate the elegance of this architecture, let us walk through a practical scenario. We are receiving live telemetry from thousands of temperature and humidity sensors deployed across an industrial manufacturing plant. We will utilize KQL to create our foundational structures, aggregate our data in real-time, and detect operational anomalies.We will open our KQL Queryset editor within our Fabric workspace and execute the following foundational code.// KQL Script for Fabric Real-Time Analytics KQL Database// 1. Create target table for incoming IoT Eventstream.create table DeviceTelemetry ( DeviceId: string, Temperature: real, Humidity: real, Timestamp: datetime)// 2. Define a Materialized View for real-time minute-by-minute aggregation.create materialized-view DeviceSummary on table DeviceTelemetry{ DeviceTelemetry | summarize AvgTemp = avg(Temperature), MaxTemp = max(Temperature), Count = count() by DeviceId, bin(Timestamp, 1m)}// 3. Time-Series Anomaly Detection query over real-time streamDeviceTelemetry| make-series AvgTemp=avg(Temperature) default=0 on Timestamp from ago(2h) to now() step 1m by DeviceId| extend (Anomalies, Score, Baseline) = series_decompose_anomalies(AvgTemp, 2.5)| render timechart with (title="IoT Temperature Anomalies Real-Time")Step 1: Establishing the Target TableOur first operation is beautifully straightforward. We use the .create table control command to define the schema for our incoming IoT data. We define the DeviceId as a string, our sensor readings (Temperature and Humidity) as real numbers, and crucially, we establish our Timestamp column. When we mapped our Eventstream destination earlier, we instructed Fabric to continuously append the incoming JSON payloads directly into this DeviceTelemetry table.Step 2: The Power of Materialized ViewsIn a real-time scenario, our sensors might generate hundreds of readings per second per device. If we attempt to run heavy analytical dashboards directly against this raw table, we will force the engine to repeatedly scan and aggregate millions of raw rows on every page refresh.To ensure our dashboards render instantly, we deploy a Materialized View named DeviceSummary. Unlike standard SQL views, a KQL Materialized View physically pre-aggregates the data in the background as it arrives. We instruct the engine to group the incoming telemetry using the bin(Timestamp, 1m) function, effectively truncating the timestamp to the nearest minute. We then calculate the average temperature, the maximum temperature, and the total event count. When our business users open their reporting tools, they query this lightweight, pre-calculated DeviceSummary view, experiencing sub-second performance regardless of how large the underlying raw data grows.Step 3: Native Time-Series Anomaly DetectionThe most impressive capability of the KQL engine is its native time-series functionality. Historically, if we wanted to detect anomalies in a data stream, we had to export the data to a Spark cluster, load a heavy machine learning library like Scikit-Learn, train a model, and write the predictions back to a database.With KQL, we accomplish complex machine learning directly within the query execution engine. In our script, we utilize the make-series operator to transform our raw telemetry into a structured, gap-filled time-series array, ensuring we have a continuous data point every minute for the last two hours (ago(2h) to now()).We then pass this array into the remarkably powerful series_decompose_anomalies function. This built-in machine learning function automatically applies Seasonal Trend Loess (STL) decomposition to our live data. It instantly identifies the underlying baseline trend, isolates expected seasonal patterns, and scores any remaining variance against a sensitivity threshold (which we set to 2.5).Finally, by appending the | render timechart command, the KQL engine natively generates a visual chart plotting our temperatures, highlighting the exact moments our industrial machinery experienced an anomalous temperature spike. We achieved advanced operational intelligence without writing a single line of Python or provisioning a single ML cluster.Wiring KQL Data directly into Power BI Real-Time DashboardsHaving successfully ingested, aggregated, and analyzed our telemetry, our final architectural mandate is delivering these insights to our end-users. After all, the fastest query engine in the world is useless if the visualization layer introduces unacceptable latency.Within Microsoft Fabric, we seamlessly bridge the gap between the KQL Database and our reporting layer using Power BI. However, we explicitly avoid using standard Power BI Import Mode, as scheduled refreshes would instantly defeat our real-time objective. Instead, we have two highly optimized paths available to us.First, we can connect our standard Power BI semantic models directly to the KQL Database using DirectQuery mode. Because the Kusto engine processes queries in milliseconds, DirectQuery performs exceptionally well, allowing our executives to filter and slice millions of rows of live telemetry without moving the data.Second, and perhaps more impactfully, we can leverage the native Real-Time Dashboards artifact within Fabric. These dashboards are fundamentally integrated with the Kusto engine. We simply paste our anomaly detection KQL queries directly into the dashboard tiles, configure an automatic refresh interval (for instance, every 10 seconds), and publish. The dashboard continuously polls the KQL engine, ensuring our operations center sees the absolute latest machinery status with sub-second latency.ConclusionWe no longer need to accept the latency of legacy batch processing. By embracing Real-Time Intelligence in Microsoft Fabric, we construct a streamlined, elegant architecture that transforms raw events into actionable insights at the speed of thought.We utilize Fabric Eventstream to effortlessly capture high-velocity telemetry. We leverage the unparalleled speed of the KQL Database to ingest, index, and query that data instantly. Finally, we execute native machine learning functions to detect anomalies on the fly, delivering sub-second insights directly to our stakeholders through dynamic dashboards. Moving forward, we will continue to build responsive, AI-native platforms that ensure our organizations are never reacting to yesterday’s news, but actively managing today’s reality.Hey, I am Sandip Palit, from Kolkata, India. I love to explore what’s new in the Data Science space and share it with the community. I am a Fabric Super User, and in this Microsoft Fabric Playlist, I will share my learnings on Microsoft Fabric and the tips and tricks of using it effectively..Thank You for reading this article. Please feel free to share your thoughts in the comments section, and give this article a 🌟.From Eventstream to KQL Database: Sub-Second Real-Time Analytics in Microsoft Fabric was originally published in Towards AI on Medium, where people are continuing the conversation by highlighting and responding to this story.