Select, Detect, Act, or why I consider Reflex being a watchdog

Reflex is many things next to one of the workloads of Microsoft Fabric. Before I delve into these things in more detail in later articles (yes, maybe this is the birth of another series of articles), I want to say this: Reflex is cool. It was never that simple to watch your data in your Power BI datasets (and this is only one of the capabilities of Reflex).

Because I need images whenever I try to understand things, I start with a simple image of Reflex: I consider Reflex a watchdog! Reflex is watching something and alarms me or someone else when something happens - a defined condition is met.

It will be likely that the first thing you ask Reflex to watch is a measure in one of your Power BI datasets. The dataset I use in this article is the dataset that holds the status of my on-premises data gateways.

I store the status of each on-premises data gateway in a delta table-you can read about this here: (https://www.minceddata.info/2023/10/16/power-bi-gateway-monitoring-and-more-using-microsoft-fabric/) I defined a measure that returns 1 if the status of the gateway is “NotReachable.” This status indicates that something has happened, and the Power BI Service cannot use the gateway to support import and Direct Query solutions. This measure is simple:

a new Measure = 
var maxActivityDateTime = CALCULATE( MAX( 'view1'[activityDateTime] ) )
    COUNT( 'view1'[GatewayStatus] )
    , 'view1'[GatewayStatus] = "NotReachable"
    , 'view1'[activityDateTime] = maxActivityDateTime

The table ‘view1’ holds the status information about all the on-premises data gateways. The measure returns a value that is greater than 0 when the status of one the gateways becomes “NotReachable.” This measure returns the value only for the latest available status. The timestamp is created inside the notebook that is retrieving the status information and stored to the delta table.

The trigger (select/detect)

Defining the trigger (or training the watchdog what to look out for is simple), at least after scanning the documentation (start here: https://learn.microsoft.com/en-us/fabric/data-activator/data-activator-get-started?WT.mc_id=DP-MVP-5003068).

From inside a Power BI report that is published to a workspace where Fabric capabilities are enabled hit the “Trigger action” comand from a visual that is visualizing the measure, like the following data visualization:

Please, dear reader, do not think about the usefulness of the data viz. It’s only used to configure the “Reflex” initially.

The following image shows the initial configuration of a reflex:

There are four steps necessary to configure the reflex initially:

  1. Select the measure that you want to be evaluated (or watched by the watchdog). At the moment of writing this article (October 2023) only a measure that is part o the visual can be selected.
  2. For each, … This defines the granularity of the measure evaluation. It took me some time to realize that this becomes only available if the categorical variable or column of the dimension table is part of the visual. I started out with a card visual, but was never be able to select the id column (the id of the on-premieses data gateway).
  3. The frequency, … This defines the frequency how often the watchdog will look out for the defined measure. Make sure that this will match the frequency of the data update. If new data is added to the delta table is does not make sense to evaluate the measure every 5 minutes.
  4. The condition, … This was a little mind-boggling in the beginning, because I wasn’t aware that Reflex creates a baseline when the watching period gets started. My measure returns 0 when everything is fine, because there are no records at the latest activity date time with the gateway status “NotReachable.”

I tried to be extra smart and stopped the gateways to have unwanted but expected in my table. Due to the baseline Reflex creates when it’s started, reflex “stored” the current value for each item (each id, the id of the on-premises data gateway). The condition “Becomes greater than 0” was never met, because the baseline already started with a value greater than 0. I have to admit that I was on my way to start swearing, before I realized this user error.

How to change the initial configuration using the Design mode of the reflex will be part of one of the next articles.

the event

This of course is one of the most important parts, this is about notifying the interested audience that a certain condition was met. My favorite sink is a Teams channel, each “alert” becomes a card that then can be discussed by the team that is watching the selected channel.

I already mentioned that it was never that simple to create alerts that create a message in teams. I consider this capability amazing


Thank you for reading!

Kommentar schreiben

Kommentare: 0