3: Monitor and optimize an analytics solution

    Monitor data ingestion

    Ingestion in Microsoft Fabric flows through three main surfaces: data pipelines and their Copy activity, Dataflows Gen2 refreshes, and Eventstreams. Each surface emits its own run telemetry, and the Monitor hub is the single workspace-wide place to triage them. The challenge is not whether telemetry exists, it is whether you can join it together quickly enough to find the root cause when a downstream Lakehouse table or KQL Database stops receiving rows.

    The Monitor hub lists every item run scoped to the current workspace and lets you filter by item type, status, submitter, capacity, and time window. Each row drills down into an item-specific run details page. For pipelines, that means activity-level inputs, outputs, error details, and runtime. For dataflows, it shows the staged query graph and which step failed. For notebooks, it links to the Spark application, executors, stages, and SQL plans. For Eventstream, it surfaces ingestion lag, dropped events, and operator-level row counts.

    A monitoring strategy that scales beyond a handful of items splits responsibility into three layers. The first layer is operational health: is the item running, is it finishing inside its SLA, and is it consuming a reasonable share of capacity. The second layer is data quality: did the expected number of rows arrive, are they conforming to the schema, and are watermarks advancing. The third layer is cost and capacity: is the item driving throttling on its F SKU, is it bursting, and is it being smoothed across the rolling 24-hour window. Confusing these layers leads to chasing red status icons that are not the real problem, while a slow but successful run quietly burns capacity units.

    Capacity is the second pillar of ingestion monitoring. The Microsoft Fabric Capacity Metrics app reports capacity-unit (CU) usage by operation, by item, and by workspace, and shows when smoothing is hiding short bursts that exceed the SKU. Pipeline Copy activities, Dataflow Gen2 refreshes, and Eventstream operations each have a published CU billing meter. When a workspace shows interactive throttling, query and refresh operations are delayed; under background throttling, items are rejected. Monitoring the metrics app alongside the Monitor hub answers the question that the hub alone cannot answer: did this slow run hit a capacity ceiling or a data ceiling.

    πŸ’‘ Exam Trap: The Monitor hub is workspace-scoped. To monitor an operation across multiple workspaces, you either browse each workspace separately or query the Fabric Capacity Metrics app, which is tenant-scoped at install time and aggregates across workspaces in the same capacity.

    πŸ“Š Limit: Pipeline run history in the Monitor hub is retained for 30 days. To keep ingestion telemetry longer, write a notebook or pipeline that calls the Fabric REST API on a schedule and persists results to a Lakehouse table.

    Identify and resolve Eventstream errors

    Eventstreams are the streaming counterpart of pipelines, and their error surface is different from batch tooling. Each Eventstream is a graph of sources, operators, and destinations running on Fabric capacity. The Eventstream editor includes a Data preview pane and a Data insights pane that show event counts per minute, total events ingested, and an error log per item in the graph. When an error appears, the operator turns red and an error message is attached to the configuration panel.

    The recurring Eventstream error families are source connectivity, authentication, schema, and destination throttling. A source like Azure Event Hubs or IoT Hub fails when its shared access key has been rotated or its consumer group has been removed. A custom endpoint source fails when client authentication uses a connection string that has lost its policy. A CDC source fails when the upstream database has not enabled change data capture, has run out of log retention, or sits behind a private network that the Fabric capacity cannot reach. In every case, the error is shown both inline on the operator and in the run history.

    Schema errors are subtler. Eventstream operators infer the schema either from the source contract or from a sample. When an upstream producer adds a column with a name that includes characters outside the supported set, or sends a JSON document where a previously scalar field becomes an array, downstream operators fail with type mismatch errors. The fix is to add an explicit Manage fields operator that projects the columns you depend on and to use a derived stream with explicit schema for downstream consumers, so upstream schema drift does not break every destination in the same graph.

    Destination errors usually surface as throttling. A KQL Database destination throttles when the ingestion batch policy fills up, a Lakehouse destination throttles when the underlying Delta table has too many small files and write contention spikes, and a custom endpoint destination throttles when the consuming application falls behind. The remediation pattern is to inspect the destination's ingestion latency in its own monitoring view (the KQL Database has an ingestion latency panel; the Lakehouse exposes Delta operation history), then either widen the destination's compute footprint or thin the upstream flow by adding aggregation operators ahead of the destination.

    🎯 Scenario: An Eventstream that fans IoT telemetry into both a KQL Database and a Lakehouse turns its Lakehouse destination red. Live metrics show ingestion lag rising linearly. Delta history on the destination table shows hundreds of OPTIMIZE conflicts. Root cause: the Lakehouse table has no partitioning and concurrent writers are colliding on small files. The fix is to recreate the destination table with a partition column (for example, ingestion date), enable V-Order, and run OPTIMIZE on a schedule.

    ⚠️ Anti-Pattern: Adding a transformation operator inside the Eventstream graph to filter out malformed events without logging them. When you discover next week that 8% of rows are missing, there is no audit trail. Add a parallel destination that captures malformed events to a quarantine Lakehouse table instead.

    Optimize query performance

    Query performance optimization on the ingestion side is about keeping ingestion queries fast enough that they finish inside their window. There are three engines to think about: T-SQL on the Warehouse and the SQL analytics endpoint, KQL on the Eventhouse, and Spark SQL on the Lakehouse.

    T-SQL queries against the Warehouse rely on result-set caching, statistics, and the distributed query optimizer. A query that suddenly slows down on a previously fast table is usually missing statistics on a join key or a predicate column. The Warehouse maintains automatic statistics on most workloads, but bulk loads that bypass the standard insert path can leave them stale. Running CREATE STATISTICS or UPDATE STATISTICS on the join and filter columns restores the optimizer's row estimates. A second class of slowdowns comes from cross-database joins between a Warehouse and a Lakehouse SQL analytics endpoint that lives in another workspace; review the join order and consider materializing intermediate results in a local Warehouse table to avoid repeated reads across the boundary.

    KQL on the Eventhouse uses different levers. The KQL Database materializes hot data in a query cache governed by a caching policy and an extents merge policy. Queries that scan more than the hot cache fall back to cold extents stored in Azure Blob Storage and run several times slower. The KQL set table policy caching command sets the hot window, and queries that always scan beyond the configured hot window are flagged by the diagnostic logs. Materialized views (.create materialized-view) precompute frequent aggregations and accelerate dashboard queries that would otherwise scan months of raw events.

    Spark SQL on the Lakehouse benefits from V-Order, OPTIMIZE compaction, partition pruning, and Adaptive Query Execution (AQE). A Lakehouse table read by Power BI through Direct Lake also benefits because Direct Lake uses the same Delta files. The two practical levers for query slowness are file layout (compact small files, prefer V-Order on tables that feed semantic models) and predicate design (always include the partition column in WHERE clauses when the table is partitioned, and prefer ZORDER on columns with selective filters that are not part of the partition scheme).

    -- T-SQL: refresh statistics on a Warehouse table after a bulk load
    UPDATE STATISTICS dbo.sales_fact WITH FULLSCAN;
    
    -- Inspect query plans to find missing statistics
    SELECT TOP 50
     qsqt.query_sql_text,
     qsrs.avg_duration,
     qsrs.last_execution_time
    FROM sys.query_store_query_text qsqt
    JOIN sys.query_store_query qsq ON qsqt.query_text_id = qsq.query_text_id
    JOIN sys.query_store_plan qsp ON qsq.query_id = qsp.query_id
    JOIN sys.query_store_runtime_stats qsrs ON qsp.plan_id = qsrs.plan_id
    ORDER BY qsrs.avg_duration DESC;
    
    // KQL: set a 7-day hot cache on the events table
    .alter table TelemetryEvents policy caching hot = 7d
    
    // Show query duration percentiles per table
    .show queries
    | where StartedOn > ago(1h)
    | summarize p50=percentile(Duration, 50),
     p95=percentile(Duration, 95),
     p99=percentile(Duration, 99)
     by Table=tostring(extract(@"from\s+(\w+)", 1, Text))
    | order by p95 desc
    
    # Spark SQL: enable AQE and check Delta file layout
    spark.conf.set("spark.sql.adaptive.enabled", "true")
    spark.conf.set("spark.sql.adaptive.coalescePartitions.enabled", "true")
    spark.conf.set("spark.sql.adaptive.skewJoin.enabled", "true")
    
    spark.sql("DESCRIBE DETAIL fabric_lakehouse.sales_fact").show(truncate=False)
    spark.sql("DESCRIBE HISTORY fabric_lakehouse.sales_fact").show(truncate=False)
    

    πŸ’‘ Exam Trap: A Warehouse query that ran fast yesterday and is slow today after a large COPY INTO is the textbook symptom of stale statistics. Reaching for partitioning or distribution changes first is wrong, because Warehouse manages physical layout for you. Update statistics first.

    πŸ“Š Limit: KQL hot cache size is bounded by the SKU's eligible cache size. When the hot policy across all tables exceeds it, oldest extents are evicted from cache even if their policy says hot.

    Decision Anchor: Where to investigate an ingestion slowdown first

    Choose the Monitor hub when the question is "did the run start, did it finish, did it error". Choose the Fabric Capacity Metrics app when the question is "did capacity throttling cause the slowdown". Choose the item-native monitoring (Dataflow refresh history, Eventstream live view, Spark UI, KQL diagnostic logs) when the question is "which step or query inside the run is the bottleneck". The mistake is starting in the metrics app for every problem; throttling causes only a fraction of slowdowns, and most run-time issues are visible in the Monitor hub.


    Continue with the interactive course

    Track your progress, jump into practice questions and use the Shark AI tutor inside the Microsoft - DP-700 learning hub.