Skip to main content Link Menu Expand (external link) Document Search Copy Copied

Task 03: Analyze data by using KQL and anomaly detection

Introduction

Once data is streaming into the KQL database, you can analyze it using KQL and configure alerts for anomalies.

Description

In this task, you’ll query streaming data and configure anomaly detection and alerts.

Example scenario

Sudden temperature drops may indicate equipment failure and require immediate attention.

Success criteria

Queries return results and alerts trigger when conditions are met.

Learning resources

  • Kusto Query Language (KQL) basics
  • Anomaly detection in Fabric

Key steps

01: Query streaming data and configure anomaly detection

  1. Open Microsoft Edge and go to https://app.powerbi.com/.

  2. If prompted, sign in by using the following credentials:

    Setting Value
    Username @lab.CloudPortalCredential(User1).Username
    Temporary Access Pass (TAP) token @lab.CloudPortalCredential(User1).AccessToken
  3. In the left pane, select the Zava@lab.LabInstance.Id workspace.

    8merzz0d.jpg

  4. In the list of resources, select the thermostat KQL database.

    Be sure to select the thermostat KQL database resource and not the thermostat Eventhouse resource.

    dj66ch39.jpg

  5. On the command bar for the database, select Query with code.

    touc3vz2.jpg

  6. On the command bar for the database, select Copilot.

    2o0b2gu9.jpg

  7. Submit the following prompt:

     What is the average temperature per day?
    
  8. In the response from Copilot, select Copy to clipboard>

    icu08hzs.jpg

  9. Paste the query from Copilot into the query window.

    Sometimes when you paste responses from the Copilot window, in addition to pasting the comments and code, HTML markup gets pasted.

    5c4a6gzi.jpg

    You must remove the HTML markup tags that appear before or after the comments and code.

    fcqsj12h.jpg

  10. On the command bar, select Run.

    d1mwfsxb.jpg

    0xg77og2.jpg

  11. In the left pane, select the Zava@lab.LabInstance.Id workspace.

    8merzz0d.jpg

  12. On the command bar, select + New item.

  13. Search for Activator.

    okr2vgs2.jpg

  14. Select Get data.

    0suvx4fc.jpg

  15. In the Data section, select RealtimeDataTo-KQLDB-stream.

    6yet00pz.jpg

  16. Select Next.

    j8wrnwzg.jpg

  17. []Select Connect.

    nlj4w6tp.jpg

  18. Select Finish.

    25e9q2m9.jpg

  19. Select New Object.

    zrna8tj8.jpg

  20. Configure the Build object pane by using the following information:

    Field Value
    Object Name Thermostat
    Unique identifier Device Id

    You may not be able to enter information into these fields until you start seeing data in the Event details pane that appears at the bottom of the window.

    It may take a couple of minutes before you start seeing data. If you cannot configure the object, close the Build object pane and select New object to reopen the pane.

  21. Select each of the following properties:

    • Battery level
    • City
    • Temp
    • StoreID
    • EnqueuedTimeUTC
  22. Select Create.

    e3fhhphq.jpg

  23. In the Explorer pane, in the Thermostat node, select Battery level.

    eccb4qtc.jpg

  24. In the right pane, select New rule.

    718vro7q.jpg

  25. Configure the alert rule Condition section by using the following information:

    Field Value
    Condition Decreases below
    Value 10
    Occurrence Every time the condition is met

    0g7l0ros.jpg

  26. Select Save and Start.

    lxytct8e.jpg

  27. Once we have streaming data which matches with the alert condition we should start seeing Email actions getting triggered.